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

CheckBoxList绑定后没Value值

2013-07-04 
CheckBoxList绑定后没有Value值本帖最后由 humanpally 于 2013-06-26 15:03:40 编辑cblRole是一个CheckBox

CheckBoxList绑定后没有Value值
本帖最后由 humanpally 于 2013-06-26 15:03:40 编辑 cblRole是一个CheckBoxList,分别使用了下面2种方法来绑定,在js中去取值,发现取到的value为 on, dt_Role中存在列"ID"并且不为空


            
            cblRole.DataTextField = "Name";
            cblRole.DataValueField = "REMARK";
            cblRole.DataSource = dt_Role.Copy();
            cblRole.DataBind();


            foreach (DataRow dr in dt_Role.Rows)
            {
                ListItem obj = new ListItem(dr["Name"].ToString(), dr["ID"].ToString());
                cblRole.Items.Add(obj);
            }
            cblRole.DataBind();

在Chrome中审查元素发现这个checkboxList的代码,input缺少了value的值,

<table id="cblRole" border="0">
<tbody>
<tr>
<td><input id="cblRole_0" type="checkbox" name="cblRole$0"><label for="cblRole_0">系统管理员</label></td>
<td><input id="cblRole_1" type="checkbox" name="cblRole$1"><label for="cblRole_1">VM管理员</label></td>
<td><input id="cblRole_2" type="checkbox" name="cblRole$2"><label for="cblRole_2">部门经理</label></td>
<td><input id="cblRole_3" type="checkbox" name="cblRole$3"><label for="cblRole_3">最终用户</label></td>
</tr>
</tbody></table>


这个页面在另外一个项目中是正常工作,绑定后input中也是有值的,如 <input id="cblRole_0" type="checkbox" name="cblRole$0" value="1">,不知道有没有人碰到过相同的情况,应该怎么解决
------解决方案--------------------


http://www.cnblogs.com/binw/archive/2011/12/27/2304161.html
[解决办法]
参考http://blog.csdn.net/dj1232090/article/details/2452905

热点排行