DropDownList -- setting by text?

M

matt

hello,

what is the most-effcient manner to set the selected-item of an
existing dropdownlist, when you only have the text (not the value) of
the to-be-selected-item?

currently, this is what im doing:

ddlIFoo.SelectedValue = ddlIFoo.Items.FindByText(theText).Value;



thanks!
matt
 
A

Alessandro Zifiglio

Matt, have you had problems with the FindByText and FindByValue method ?
I'd say its time to move on if this is working for you. From what you are
trying to achieve, it seems to me that you want to Find-By-Text and are
indeed using the right method. If you are unhappy with this, then you can
manually loop through all items till you find a matching item whose
ListItem.Text matches the Text you want to match, while setting that
listItems.selected property to true. Not very elegant and unnecessary since
you would be reinventing the wheel =P

Regards,
Alessandro Zifiglio
http://www.AsyncUI.net
 

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

No members online now.

Forum statistics

Threads
474,104
Messages
2,570,643
Members
47,247
Latest member
youngcoin

Latest Threads

Top