Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

set selected item in databound dropdownlist

Status
Not open for further replies.

tembalena

Programmer
Apr 17, 2001
37
ZA
I have a member's profile form, the dropdownlists populated with his data. How do I set the selected item of a dropdownlist?
eg. Gender = Male or Female, how do I set the gender value to that which I've retrieved from this member's gender property? Thanks.
 
drpList.items.findbytext("male").selected = true

or

drpList.items.findbyvalue("1").selected = true

or

drpList.selectedIndex = 0

I like the .findByText methods there because they are easier to use, but beware they will throw an exception if the text is not found, so I'd suggest the following block to handle it:

try
drp.items.findbytext("male").selected = true
catch
drp.selectedIndex = 0
end try

paul
penny1.gif
penny1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top