Sami
Sami

Reputation: 3976

get dropdownlist selectedvalue on button click in ListView

I have DropDownList and a button in ListView for each row. Now i want to get the selected value of the dropdownlist on Button click event. How can i get this.

Please guide me.

Thanks.

Upvotes: 0

Views: 2650

Answers (3)

TC.
TC.

Reputation: 4183

Set the CommandName property of your buttons, handle the ItemCommand event of your listview, and use FindControl to find the DropDownList.

For reference, see

Upvotes: 2

Nathan Q
Nathan Q

Reputation: 1902

EDIT: on second thoughts, use answer of TC..


in the button click event do something like:

Button b = (Button)sender;
DropDownList ddl = (DropDownList)b.Parent.FindControl("DropDownList ID");
string DropDownListSelectedValue = ddl.SelectedValue;

Upvotes: 0

Kinexus
Kinexus

Reputation: 12904

DropDownList.SelectedValue will get the current selected value.

Upvotes: 0

Related Questions