asp.net – 如何绑定gridview中数据表的复选框值
发布时间:2020-12-16 04:27:36 所属栏目:asp.Net 来源:网络整理
导读:我需要弄清楚如何在GridView中绑定CheckBox值,我在GridView中编写了CheckBox.Checked = DataBinder.Eval(Container.DataItem,“IsSubscribed”),但是即使IsSubscribed为false,也会检查CheckBox. 在页面回发之前,我已经在Page_Load中绑定了网格.这是我的代码
我需要弄清楚如何在GridView中绑定CheckBox值,我在GridView中编写了CheckBox.Checked = DataBinder.Eval(Container.DataItem,“IsSubscribed”),但是即使IsSubscribed为false,也会检查CheckBox.
在页面回发之前,我已经在Page_Load中绑定了网格.这是我的代码: <asp:TemplateField HeaderText="Select"> <ItemTemplate> <asp:CheckBox ID="chkIsSubscribed" runat="server" HeaderText="IsSubscribed" Checked='<%# DataBinder.Eval(Container.DataItem,"IsSubscribed") %>'/> </ItemTemplate> </asp:TemplateField> 谢谢. 解决方法
将此代码作为您的项目模板元素:
<asp:TemplateField HeaderText="Select"> <ItemTemplate> <asp:CheckBox ID="chkIsSubscribed" runat="server" HeaderText="IsSubscribed" Checked='<%#bool.Parse(Eval("IsSubscribed").ToString())%>' /> </ItemTemplate> </asp:TemplateField> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 得墨忒耳定律和OOP混淆
- asp.net-mvc – 如何为ASP.NET MVC站点定义catch-all路由?
- 本地化 – MVC 3中DataAnnotations的默认错误消息的整个列表
- .NET Core和Classic ASP在同一解决方案中?
- 自动完成后的事件填写Asp.net C#或javascript / html,
- 如何在ASP.NET中删除/放弃请求?
- ASP.NET MVC使用JQuery将页面内容加载到div中
- asp.net-mvc – 在ASP.NET MVC中下载动态生成的文件
- asp.net-mvc – AngularJS无法在发布模式下工作(缩小)
- asp.net-mvc – 默认情况下,Html.TextArea会生成额外的换行
推荐文章
站长推荐
热点阅读