Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 4.0 编辑栅格视图记录时出错_C# 4.0_C# 3.0 - Fatal编程技术网

C# 4.0 编辑栅格视图记录时出错

C# 4.0 编辑栅格视图记录时出错,c#-4.0,c#-3.0,C# 4.0,C# 3.0,在2页的网格视图上单击“编辑”按钮时,出现以下错误 System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index 您能指定我应该做什么来删除此错误吗 下面是编辑命令的代码,当我在第一个页面上时,它工作得很好,但是如果我在网格视图中转到另一个任意页面,它就会出现错

在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);
        }
    }

错误日志显示索引超出范围,请查看集合

GVviewReminder.Rows[Convert.ToInt32(e.CommandArgument)]

selectedRow.Cells[1].Text