索引超出范围。必须为非负值并小于集合大小。参数名: index
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.ArgumentOutOfRangeException: 索引超出范围。必须为非负值并小于集合大小。参数名: index源错误:
行 55: sqlConnection1.Close();
行 56: ViewState["currentpage"]=currentpage;
行 57: ViewState[currentpage.ToString()]=DataGrid1.Items[0].Cells[0].Text;
行 58: if(DataGrid1.Items.Count<DataGrid1.PageSize)
行 59: {
源文件: c:\inetpub\wwwroot\divpage\webform1.aspx.cs 行: 57 堆栈跟踪:
[ArgumentOutOfRangeException: 索引超出范围。必须为非负值并小于集合大小。
参数名: index]
System.Collections.ArrayList.get_Item(Int32 index) +91
System.Web.UI.WebControls.DataGridItemCollection.get_Item(Int32 index)
divpage.WebForm1.fillgrid(SqlCommand currentcommand) in c:\inetpub\wwwroot\divpage\webform1.aspx.cs:57
divpage.WebForm1.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\divpage\webform1.aspx.cs:42
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.ArgumentOutOfRangeException: 索引超出范围。必须为非负值并小于集合大小。参数名: index源错误:
行 55: sqlConnection1.Close();
行 56: ViewState["currentpage"]=currentpage;
行 57: ViewState[currentpage.ToString()]=DataGrid1.Items[0].Cells[0].Text;
行 58: if(DataGrid1.Items.Count<DataGrid1.PageSize)
行 59: {
源文件: c:\inetpub\wwwroot\divpage\webform1.aspx.cs 行: 57 堆栈跟踪:
[ArgumentOutOfRangeException: 索引超出范围。必须为非负值并小于集合大小。
参数名: index]
System.Collections.ArrayList.get_Item(Int32 index) +91
System.Web.UI.WebControls.DataGridItemCollection.get_Item(Int32 index)
divpage.WebForm1.fillgrid(SqlCommand currentcommand) in c:\inetpub\wwwroot\divpage\webform1.aspx.cs:57
divpage.WebForm1.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\divpage\webform1.aspx.cs:42
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
这句前加个判断
if (DataGrid1.Items.Count == 0)
{}
用 string 索引器 就好了 也就是找名字 就不会出项越界了我是小菜鸟! 说的不好清见谅, 希望能够帮到你!