C#datagridview复选框 [英] c# datagridview checkbox

查看:82
本文介绍了C#datagridview复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将DataGridview与checkbox colum一起使用.我可以将数据从datagridview与checkbox colum一起插入数据库中.
但是我已经从数据库中读取了数据到复选框(我的意思是我需要选中复选框以检查特定的数据库记录值).我们如何做到这一点请帮助我............

I am using DataGridview with checkbox colum.I can Insert data to database from datagridview with checkbox colum.
But i have read data from database to checkbox(i mean i need checkbox as checked for particular database record value).how can we do this please help me............

推荐答案

代表复选框的数据值需要作为布尔值进行管理.
您可以使用datagridviewcheckboxcolumn的选定状态并将其转换为布尔值,同时保存在数据库中.
The data value which represents checkbox need to be managed as a boolean value.
you can use selected state of the datagridviewcheckboxcolumn and convert it into boolean value while saving in the DB.


<asp:templatefield headertext="CheckBox" itemstyle-horizontalalign="Center" xmlns:asp="#unknown">
         <itemtemplate>
<asp:checkbox id="Chk1" runat="server" checked="<%#Eval("Check") %>" />                  
         </itemtemplate> 

</asp:templatefield>





"Check" is the field name which we select from the database 
and that field in database shoult be bit


这篇关于C#datagridview复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆