In the template column of the GridView or DataGrid Control, place the DropDownList control. By changing the value of the DropDownList control, you can change other information of this row in the GridView.
Specific implementation methods:
Code
1 protected void Drpd_SelectedIndexChanged (object sender, EventArgs e)
2 {
3
4 DropDownList drp = sender as DropDownList; // The DropDownList that triggers the event
5 GridViewRow row = drp. NamingContainer as GridViewRow; // The current row of the GridView instantly contains the row information in the container where the dropdownlist is located.
6 row. Style. Add (HtmlTextWriterStyle. BackgroundColor, drp. SelectedValue );
7 Response. Write (row. RowIndex + 1); // obtain the row number of the row selected in the dropdownlist.
8 // Response. Write (String. Format ("select row {0}", row. RowIndex + 1 ));
9 DropDownList ddlClass = (DropDownList) sender;
10 string ClassID = ddlClass. SelectedValue. ToString (); // obtain the selected value of Dropdownlist
11 // Response. Write (ClassID );
12}
13
Obtain the row number under the SelectedIndexChanged event of dropdownlist.