i inserted a drop down list into my grid view from the code behind like it is done here Convert gridview field into Dropdownlist i need to make command in the row that contains this dropdownlist when its selected index is changed. please can some one hepl me thanks
If you need to get the GridViewRow
of a DropDownList
which was generated dynamically use following approach.
Add the same SelectedIndexChanged
-event handler to the dropdowns. Handle it, cast sender
to DropDownList
, cast it's NamingContainer
to GridViewRow
. Now you are all set.
protected void DropDown_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList ddl = (DropDownList) sender;
GridViewRow row = (GridViewRow) ddl.NamingContainer;
// now you get the reference to the other controls via row.FindControl
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.