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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting the selectedIndex property

Status
Not open for further replies.

rotsey

Programmer
Nov 23, 2004
135
AU
Hi,

How do you set the selectedIndex property of a dropdownlist if you know the "text" property.

Something like this

drp.selectedIndex.Indexof(mystring)

i have seen it somewhere?????

rotsey

 
You can use the DropDownList1.Items.FindByText method to return a listitem and just set the selectedIndex accordingly

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Code:
ddl.SelectedIndex = ddl.Items.IndexOf(ddl.Items.FindByText("TEXTVALUE"))

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
thanks checkai, thats what I was after
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top