System.IndexOutOfRangeException: Cannot find table 0.---原因不知道
错误提示:第一次可以load该页面,当dropdownlist里的值发生改变时页面就出错了.Exception Details: System.IndexOutOfRangeException: Cannot find table 0.
Source Error:
Line 74: //DropDownList1.Items.Clear();
Line 75: //DropDownList2.Items.Clear();
Line 76: foreach(DataRow dr in ds.Tables[0].Rows)
Line 77: DropDownList1.Items.Add(dr[1].ToString());
Line 78: DropDownList1.SelectedValue = DropDownList1.Items[1].ToString();
if(!Page.IsPostBack)
//在下拉框加入所有在产产品以供选择
ds = searchdate.SearchAllProduct();
//DropDownList1.Items.Clear();
//DropDownList2.Items.Clear();
foreach(DataRow dr in ds.Tables[0].Rows)
DropDownList1.Items.Add(dr[1].ToString());
DropDownList1.SelectedValue = DropDownList1.Items[1].ToString();
//在下拉框加入所有在产产品以供选择
ds = searchdate.SearchProductStation(DropDownList1.SelectedValue.Trim());
foreach(DataRow dr in ds.Tables[0].Rows)
DropDownList2.Items.Add(dr[0].ToString());