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

How to get the text from a DropDownList?

Status
Not open for further replies.

pharcyder

Programmer
Mar 12, 2002
66
DE
I'm new to ASP.NET, so please be gentle :)

I have a DropDownList with a bound datasource. One field from this source is an ID, the other the name of the item.
As DataTextField I use the name, and as DataValueField I use the ID (because it is used to filter a gridview).

Then I added a label and want this label to display the currently selected item name.
Now how would I get the selected item (not the ID!) from the DropDownList? I happen to always get the DataValueField-value, no matter if I use .Text or .Value.

Do I need to do this on the client-side with JavaScript or is there a possibility to get this value out of the DropDownList with ASP.NET-code??

Thanks in advance,
Jens

 
Okay, just found it.

It's .SelectedItem.Text, not just .Text

 
Can you paste the code you are using?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top