Situation: Assume that a data-bound gridview is added with a template column and placed in a checkbox. Then, use a button to obtain information about the selected row in the checkbox and perform other operations on the row.
Write a click event for button button1 as follows:
Protected void button#click (Object sender, eventargs E)
...{
For (INT I = 0; I <gridview1.rows. Count; I ++)
...{
Checkbox cb = (checkbox) gridview1.rows [I]. findcontrol ("checkbox1 ");
// Hide unselected rows
// If (CB. Checked! = True)
//{
// Gridview1.rows [I]. Visible = false;
//}
// Obtain the information of the selected row
If (CB. Checked = true)
...{
// Obtain the content of a column in the row
Response. Write (convert. tostring (gridview1.rows [I]. cells [2]. Text) + "<br/> ");
}
}
}
Other controls or other operations should also be implemented through this method.