protected void OnRowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "select")
{
int rowIndex = Convert.ToInt32(e.CommandArgument);
GridViewRow row = GridView1.Rows[rowIndex];
string name = row.Cells[1].Text;
}
}
单击按钮时,我试图从gridview表中获取名称。上面的代码适用于gridview表的第一页,但是当我单击下一页时,它抛出“索引超出范围”异常。