首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

vs2005 CheckBoxList提交时CheckBoxList1.Items.Count为0解决办法

2012-01-18 
vs2005 CheckBoxList提交时CheckBoxList1.Items.Count为0protectedvoidPage_Load(objectsender,EventArgse

vs2005 CheckBoxList提交时CheckBoxList1.Items.Count为0
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);
测试一下有没有记录

热点排行