Reputation: 25573
I use html Select in apsx page and bind it to data in database as dropdown:
<SELECT id="dd" name="dd" runat="server" DataValueField="ID" DataTextField="Name">
Then in code behind, I can get the selected item value(which is mapped to ID) as:
myvalue = dd.value;
But I want to get the selected text(which is mapped to Name), not the value in code behind. How to do it?
Upvotes: 0
Views: 12752
Reputation: 37543
myvalue = dd.SelectedText;
Edit: For a databound htmlselect you can try:
myvalue = dd.DataSource[dd.SelectedIndex][dd.DataTextField].ToString();
Upvotes: 2