protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
int rowIndex = -1;
GridViewRow row = null;
switch () ...{
case "Command1": // Template column
// For buttons in the template column, we need to display the CommandArgument property of the binding row indexed to the button
// to obtain the line information that triggers the event
rowIndex = Convert.ToInt32();
row = [rowIndex];
DisplayInfo(row, );
// your codes
//
break;
case "Command2": // Template column
// Also in the template column, but does not use the Command1 method, but uses the NamingContrainer property
// Get the current GridViewRow directly
Control cmdControl = as Control; // represents the IButtonControl that triggers the event, maintains unity and facilitates subsequent operations. Here we directly convert it into the control base class Control
row = as GridViewRow;
DisplayInfo(row, );
// your codes
//
break;
case "Command3": // Bind column
// For the ButtonField column, the CommandArgument property is automatically populated with the appropriate item index value inside the data source control.
// without us showing the commandArgument property bound
// Note that we cannot use Command2 method here. For events triggered by BUttonField,
// represents the GridView containing this button
rowIndex = Convert.ToInt32();
row = [rowIndex];
DisplayInfo(row, );
// your codes
//
break;
}
}