大家帮帮???那里错了??
数据源的类型无效。它必须是IListSource、IEnumerable或IDataSource。说明:执行当前Web请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了...
数据源的类型无效。它必须是 IListSource、IEnumerable 或 IDataSource。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.InvalidOperationException: 数据源的类型无效。它必须是 IListSource、IEnumerable 或 IDataSource。
源错误:
行 24: this.CheckBoxList1.DataTextField = "idid";
行 25: this.CheckBoxList1.DataValueField = "id";
行 26: this.CheckBoxList1.DataSource = SS;
行 27: this.CheckBoxList1.DataBind();
行 28: aac.Close();
源文件: c:\站内搜索\Default.aspx.cs 行: 26
堆栈跟踪:
[InvalidOperationException: 数据源的类型无效。它必须是 IListSource、IEnumerable 或 IDataSource。]
System.Web.UI.WebControls.DataBoundControl.ValidateDataSource(Object dataSource) +107
System.Web.UI.WebControls.BaseDataBoundControl.set_DataSource(Object value) +21
_Default.Page_Load(Object sender, EventArgs e) in c:\站内搜索\Default.aspx.cs:26
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +13
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +43
System.Web.UI.Control.OnLoad(EventArgs e) +80
System.Web.UI.Control.LoadRecursive() +49
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3750
asp.net 代码::::
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = "Provider = Microsoft.JET.OleDb.4.0;Data Source = |DataDirectory|mydata.mdb";
conn.Open();
OleDbCommand SS = new OleDbCommand("select * from news",conn);
OleDbDataReader aac=SS.ExecuteReader();
this.CheckBoxList1.DataTextField = "idid";
this.CheckBoxList1.DataValueField = "id";
this.CheckBoxList1.DataSource = SS;
this.CheckBoxList1.DataBind();
aac.Close();
conn.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{
for(int i=0;i<this.CheckBoxList1.Items.Count-1;i++)
{
if(this.CheckBoxList1.Items[i].Selected)
Response.Write(this.CheckBoxList1.Items[i].Value.ToString()+"-"+this.CheckBoxList1.Items[i].Text+"<br>");
}
}
visual c#语言编写
里面的"堆栈"信息怎么才能看懂 展开
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.InvalidOperationException: 数据源的类型无效。它必须是 IListSource、IEnumerable 或 IDataSource。
源错误:
行 24: this.CheckBoxList1.DataTextField = "idid";
行 25: this.CheckBoxList1.DataValueField = "id";
行 26: this.CheckBoxList1.DataSource = SS;
行 27: this.CheckBoxList1.DataBind();
行 28: aac.Close();
源文件: c:\站内搜索\Default.aspx.cs 行: 26
堆栈跟踪:
[InvalidOperationException: 数据源的类型无效。它必须是 IListSource、IEnumerable 或 IDataSource。]
System.Web.UI.WebControls.DataBoundControl.ValidateDataSource(Object dataSource) +107
System.Web.UI.WebControls.BaseDataBoundControl.set_DataSource(Object value) +21
_Default.Page_Load(Object sender, EventArgs e) in c:\站内搜索\Default.aspx.cs:26
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +13
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +43
System.Web.UI.Control.OnLoad(EventArgs e) +80
System.Web.UI.Control.LoadRecursive() +49
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3750
asp.net 代码::::
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = "Provider = Microsoft.JET.OleDb.4.0;Data Source = |DataDirectory|mydata.mdb";
conn.Open();
OleDbCommand SS = new OleDbCommand("select * from news",conn);
OleDbDataReader aac=SS.ExecuteReader();
this.CheckBoxList1.DataTextField = "idid";
this.CheckBoxList1.DataValueField = "id";
this.CheckBoxList1.DataSource = SS;
this.CheckBoxList1.DataBind();
aac.Close();
conn.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{
for(int i=0;i<this.CheckBoxList1.Items.Count-1;i++)
{
if(this.CheckBoxList1.Items[i].Selected)
Response.Write(this.CheckBoxList1.Items[i].Value.ToString()+"-"+this.CheckBoxList1.Items[i].Text+"<br>");
}
}
visual c#语言编写
里面的"堆栈"信息怎么才能看懂 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询