Reputation: 381
I have a datatable/source binded to a drop down list in ASP.NET C#.
I am trying to return the selected drop down list value using:
dropdownlist.Text
However, this just returns the first list value. How can i get it to return the selected drop down list value?
Upvotes: 0
Views: 487
Reputation: 658
Dropdown can return only one value. For list either you need to customize the dropdown or you need to find third party control to do that.
if You want to do it with 3rd party controls. you can try this
if you want to customize dropdown then view these
1
2
Upvotes: 0
Reputation: 17724
The dropdownlist.Text
property should work.
Make sure that you are not binding the list again on Page_Load. This would reset the SelectedValue to the first value.
Use code like
if(!IsPostBack)
{
//DataBind dropdownlist
}
Upvotes: 2