Solved

dropdown list select value

Posted on 2009-05-14
10
198 Views
Last Modified: 2013-12-17
I have a dropdown list which I want to force it to select a specific value, is this possible.
0
Comment
Question by:Mr_Shaw
  • 5
  • 3
  • 2
10 Comments
 
LVL 16

Expert Comment

by:ToddBeaulieu
ID: 24385046
Sure. Set the SelectedIndex, or find the item and set it's Selected property = True.
0
 

Author Comment

by:Mr_Shaw
ID: 24385070
There is no selected properted for a dropdown list. Please could you give me an example.
0
 
LVL 11

Expert Comment

by:srikanthreddyn143
ID: 24385081
if data is already bound to dropdownlist hten ddlist.selectedindex = index  
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:Mr_Shaw
ID: 24385114
I am binding the data from a database so I am not sure of the index value of the item i want to select.
0
 
LVL 16

Accepted Solution

by:
ToddBeaulieu earned 250 total points
ID: 24385166
Selected is an ITEM property. See, this all depends on what you're really trying to accomplish, so it's hard to guess from the original question.

If you know what the text is, you probably need to find the item and either set it to be selected or set the dropdown's selectedindex property = the item's index.

Here's an example:

http://answers.yahoo.com/question/index?qid=20070514035103AA1v20M
0
 
LVL 11

Assisted Solution

by:srikanthreddyn143
srikanthreddyn143 earned 250 total points
ID: 24385218
try it

DropDownList.SelectedValue = "somevalue"



0
 

Author Comment

by:Mr_Shaw
ID: 24385298
I need the code to actually selct not just highlight the item in the list.
0
 
LVL 11

Expert Comment

by:srikanthreddyn143
ID: 24385359
DropDownList1.Items.FindByText("text here").Selected=true;
DropDownList1.Items.FindByValue("value here").Selected = true;
0
 

Author Comment

by:Mr_Shaw
ID: 24385751
Ok thanks guys for your help.

I figured out the last part of the problem was the order in which I was calling my stored procedures.

I will dish out the point soon.

Thanks
0
 

Author Closing Comment

by:Mr_Shaw
ID: 31581448
thanks
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Media.Imaging 1 18
Reading the Web.Config using IIS 7.5? 4 36
SQL Help 27 45
SQL Query Help Top 1 and Distinct? 6 26
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question