protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
CheckBoxList1.DataSource = SDR;
CheckBoxList1.DataTextField = "name ";
CheckBoxList1.DataValueField = "id ";
CheckBoxList1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write(CheckBoxList1.Item.Count);
}
为什么会为0?
------解决方案--------------------------------------------------------
是不是没有值
------解决方案--------------------------------------------------------
EnableViewState= "true "
------解决方案--------------------------------------------------------
可以在isPostBack中加入
Response.Write(CheckBoxList1.Item.Count);
测试一下有没有记录