I got following error while i am clicked edit button on grid view for 2 page
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
can you please specify what should i have to do to remove this error
following is the code for edit command, It works well when i am on first page but gives erro if i goes to another any page in grid view
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);
}
}
The error log says index out of range so look at collections.