求助,程序问题?
using System;using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _list : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"DataSource =.\SQLEXPRESS; database=Select; uid=sa;pwd=;");
con.Open();
SqlCommand cmd=new SqlCommand ("select * from personLike",con );
SqlDataReader sdr=cmd .ExecuteReader ();
this.CheckBoxList1.DataSource =sdr ;
this.CheckBoxList1.DataTextField = "likeContent";
this.CheckBoxList1.DataValueField = "id";
this.CheckBoxList1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < this.CheckBoxList1.Items[i].Count - 1; i++)
{
if (this.CheckBoxList1.Items[i].Selected)
{
Response.Write(this.CheckBoxList1.Items[i].Text + "<br>");
}
}
}
}
这句for (int i = 0; i < this.CheckBoxList1.Items[i].Count - 1; i++)
出现 CS0117: “System.Web.UI.WebControls.ListItem”并不包含“Count”的定义,是不是还科缺少什么命名空间?
请各位帮忙看一下,谢谢!