当我单击 2 页网格视图上的编辑按钮时出现以下错误
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
你能指定我应该怎么做才能消除这个错误吗
以下是编辑命令的代码,当我在第一页时它运行良好,但如果我在网格视图中转到另一个任何页面,则会出错
protected void GVviewReminder_RowCommand(object sender, GridViewCommandEventArgs e)
{
lblError.Text = "";
if (e.CommandName == "Edit")
{
GridViewRow selectedRow = GVviewReminder.Rows[Convert.ToInt32(e.CommandArgument)];
string ID = selectedRow.Cells[1].Text;
Response.Redirect("edit_health_reminder.aspx?HealthReminderIsOpen=true&id=" + ID);
}
}