自动生成的CheckBoxList中取值问题
日期:2007-10-02 荐:
自动生成的CheckBoxList中取值问题我先用如下代码根据数据库生成了CheckBoxList及其里面的Itemsforeach (DataRow drType in dtType.Rows){DataTable dtContentType = bp.ContentType (drType["btype_id"].ToString()) ;foreach (DataRow drContentType in dtContentType.Rows){i ;CheckBoxList cbl = new CheckBoxList () ;cbl.ID = "cbl" i ;DataTable dtContentProperty = bp.ContentProperty (drContentType["book_content_type_id"].ToString()) ;foreach (DataRow drContentProperty in dtContentProperty.Rows){cbl.Items.Add (drContentProperty["PropertyName"].ToString()) ;}pContainer.Controls.Add (cbl) ;}}之后读取状态foreach (DataRow drContentType in dtContentType.Rows){i ;CheckBoxList cbl = (CheckBoxList)this.FindControl("cbl" i) ; 用for循环来取得CheckBox中的值,能编译通过,但是程序提示我i超出了范围 for (int j=0; j<cbl.Items.Count; j ){if (cbl.Items[i].Selected)sbProperty.Append ("1") ;elsesbProperty.Append ("0") ;} 用foreach来遍历,编译时候却提示我li没有Checked这个属性foreach (ListItem li in cbl.Items){if (li.Checked == true)sbProperty.Append ("1") ;else sbProperty.Append ("0") ;}}怎么才能取得里面的值啊是不是代码你都写一块了,之前的那个i的值还在?gt;>0训诙
标签: