Index was outside the bounds of the array是什么错误?怪事
程序在用到几个小时后突然出现如下错误,重启服务器后又好拉,请问何故??
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();
}