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 derfloh 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
Joined
Nov 23, 2004
Messages
135
Location
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..."
 
Or

drp.items.findbytext("Test").selected = true
 
thanks checkai, thats what I was after
 
thats not bad either shatch
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top