There are several ways to get the GridView line:
In the 1 plus Rowcommand event, determine the name of the Issued button control for the request, and according to the parameters passed, get the parameters we need in the current row.
2 GridView Set DataKeyNames mode.
The above methods are no longer burdensome.
Today to introduce one of the most convenient, but also the most satisfying day-to-day thinking of a good way:
The sender parent of the control event is used to get the cell object, and then the parent object of the cell, which is the row object. It's easy!
Examples are as follows:
In the third column, put a template column, put a checkbox, the idea is to set the fourth column lable status identified as "T", when unchecked, the fourth column lable status identity empty
Click the checkbox directly in the template column and add the following code.
Copy Code code as follows:
protected void Checkbox1_checkedchanged (object sender, EventArgs e)
{
CheckBox chk = (checkbox) sender;
DataControlFieldCell DCF = (DataControlFieldCell) chk. Parent;
GridViewRow GVR = (gridviewrow) DCF. Parent;
if (CHK). Checked)
{
Label Lab = (label) GVR. CELLS[3]. FindControl ("Label1");
Lab. Text = "T";
}
Else
{
Label Lab = (label) GVR. CELLS[3]. FindControl ("Label1");
Lab. Text = "";
}
}