RAHUL
RAHUL

Reputation: 167

Retrieving selected item value from a dropdownlist

I have a dropdownlist with a datatext field name country and a datavaluefield named countryid.

I need to get the datavaluefield's value and store it in an sql table "mytable", based on the selectedindexchanged event of the dropdownlist.

Please keep the code in C#.

Upvotes: 3

Views: 2853

Answers (2)

Azmat Ullah
Azmat Ullah

Reputation: 66

string value = ddl.SelectedItem.Text;

*This will return the selected item's text in value, which you can use in your db statements *

Upvotes: 0

Akram Shahda
Akram Shahda

Reputation: 14771

Use the following:

requestedValue = dropDownList.SelectedValue;

Upvotes: 1

Related Questions