Solved

dropdown list select value

Posted on 2009-05-14
10
199 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 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