Select an item in DropDownList in code?

L

Lee

Is there more direct way of doing this?

Dim LI As ListItem = ddUpdateType.Items.FindByValue("123")
ddUpdateType.SelectedIndex = ddUpdateType.Items.IndexOf(LI)

Not counting the check to ensure that "LI" was actually instantiated,
it's ugly in an otherwise neat group of code lines.


--
Warm Regards,
Lee

"Upon further investigation it appears that your software is missing
just one thing. It definitely needs more cow bell..."
 
B

blackstaronline.net

Are you wanting to make a certain item of the drop down the "SELECTED"
item?

Dim Ll as String = "abc"
ddUpdateType.SelectedValue = Ll

Sorry if I'm way off base here....its been a long day ;)

Jeremy Reid
http://hgtit.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top