Click here to Skip to main content
15,923,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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............
Posted

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.
 
Share this answer
 
C#
<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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900