当前位置:编程学习 > C#/ASP.NET >>

Index was out of range. Must be non-negative and less than the size of the colle

写了一个GridVIew用单选按钮选择删除多行的功能
在自己电脑上都没有问题,但是一放到服务器上GridView在第二页之后删除一个或多个就会报错
错误提示如下:

Index was out of range. Must be non-negative and less than the size of the collection
Parameter name: index


哪位能帮我解决下,谢谢了。
代码如下
~.cs

private string GetSelIDlist()
        {
            string idlist = "";
            bool BxsChkd = false;
            for (int i = 0; i < gridView.Rows.Count; i++)
            {
                CheckBox ChkBxItem = (CheckBox)gridView.Rows[i].FindControl("DeleteThis");
                if (ChkBxItem != null && ChkBxItem.Checked)
                {
                    BxsChkd = true;
                    if (gridView.DataKeys[i].Value != null)//服务器上提示是在这一行错误
                    {
                        idlist += gridView.DataKeys[i].Value.ToString() + ",";
                    }
                }
            }
            if (BxsChkd)
            {
                idlist = idlist.Substring(0, idlist.LastIndexOf(","));
            }
            return idlist;
        }
--------------------编程问答-------------------- 相同问题,顶一个,求解释! --------------------编程问答-------------------- 除 --------------------编程问答-------------------- gridView.DataKeys[i],i超出了datakeys的范围
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,