Index was outside the bounds of the array是什么错误?怪事

flashasp 2004-09-14 06:03:14
程序在用到几个小时后突然出现如下错误,重启服务器后又好拉,请问何故??
Index was outside the bounds of the array.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[IndexOutOfRangeException: Index was outside the bounds of the array.]
Ydyd.WebControls.RelatedList.RelatedListItemsFromDataSet.GenerateXmlData(StringBuilder xmlData, String parentValue)
Ydyd.WebControls.RelatedList.RelatedListItemsFromDataSet.GenerateXmlData(StringBuilder xmlData, String parentValue)
Ydyd.WebControls.RelatedList.RelatedListItemsFromDataSet.GenerateXmlData(StringBuilder xmlData, String parentValue)
Ydyd.WebControls.RelatedList.RelatedListItemsFromDataSet.GenerateXmlData(StringBuilder xmlData, String parentValue)
Ydyd.WebControls.RelatedList.RelatedListItemsFromDataSet.GenerateXmlData(StringBuilder xmlData, String parentValue)
Ydyd.WebControls.RelatedList.RelatedListItemsFromDataSet.GetClientXmlData(String controlID, Page page)
Ydyd.WebControls.RelatedList.RelatedList.InitItems()
Ydyd.WebControls.RelatedList.RelatedList.OnDataBinding(EventArgs e)
Ydyd.WebControls.RelatedList.RelatedList.DataBind()
WebAppPowerDataGridTest.sanjishu.BindRelatedList() in D:\sanjishu.aspx.cs:101
WebAppPowerDataGridTest.sanjishu.Page_Load(Object sender, EventArgs e) in D:\sanjishu.aspx.cs:39
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731
---------------------------------------------------------------------------------
private void BindRelatedList()//装载所有列表
{

string con = data.constr,sql="";
SqlConnection connection = new SqlConnection(con);
sql="select * from category";
SqlDataAdapter da = new SqlDataAdapter(sql, connection);
DataSet ds = new DataSet();
da.Fill(ds);


ArrayList b = new ArrayList();
b.Add("DropDownList5");
b.Add("DropDownList6");
b.Add("DropDownList7");
b.Add("DropDownList4");

RelatedList2.DataSource = ds;
RelatedList2.ListID = b;
RelatedList2.DataBind();
}
...全文
11617 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
ark_matrix 2004-09-16
  • 打赏
  • 举报
回复
你可以在page_load时只载入一次,但你要在修改那个list的事件完成后重新绑定一下
robert2004 2004-09-16
  • 打赏
  • 举报
回复
用了分页没
forideal 2004-09-16
  • 打赏
  • 举报
回复
数组下标溢出
flashasp 2004-09-15
  • 打赏
  • 举报
回复
难道要去掉if????
ark_matrix 2004-09-15
  • 打赏
  • 举报
回复
if (!Page.IsPostBack)
{

BindRelatedList();

}
BindRelatedList();只在页面载入时执行了一遍
flashasp 2004-09-15
  • 打赏
  • 举报
回复
郁闷,还是不行,现在是用到5分钟以后就出现这个错误,服务器一重启就好拉
李赞红 2004-09-14
  • 打赏
  • 举报
回复
数组越界
houxw 2004-09-14
  • 打赏
  • 举报
回复
索引超出数组的范围了
flashasp 2004-09-14
  • 打赏
  • 举报
回复
应该不是,我这样判断的

private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{

BindRelatedList();

}
}
yanyzty 2004-09-14
  • 打赏
  • 举报
回复
是不是页面刷新没有判断,导致每刷新一次就绑定一回list

62,244

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧