GridView / RowCommand / e.CommandArgument
In the following GridView’s RowCommand method,
public void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
e.CommandArgument is automatically set to the row index (as a string, not as an int). So if the GridView ID is GridView1, here's an easier solution to get the current RowIndex:
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = GridView1.Rows[Convert.ToInt32 (e.CommandArgument)];