Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want tick checkbox stored database in true uncheck stored database in false using gridview
Posted
Updated 29-Jan-17 7:07am
v2
Comments
CHill60 14-Dec-13 7:26am    
Ok. Why can't you do that?
So, what is the problem?

Peter Leow already has added the solution which you need. A link added below for an clear understanding on how its stored at the DB side.

http://www.wiseowl.co.uk/blog/s315/bit-true-false.htm[^]

Hope this helps...
 
Share this answer
 
Comments
Peter Leow 15-Dec-13 4:25am    
Thanks for making my solution more complete. +5 :)
JoCodes 15-Dec-13 4:41am    
Thanks Peter :)
First you have to have a table with a field say 'isChecked' of BIT type in your sql server.

Then in your C# code, if the Checked state of the checkbox is true then insert/update 1 else 0 into the 'isChecked' field of a row.
 
Share this answer
 
v3
Comments
JoCodes 15-Dec-13 4:13am    
Shouldn't have a downvote...
you can find a control with the help of gridview find control like that
C#
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
   {
       CheckBox ch = (CheckBox)GridView1.FindControl("id of your check box");
       if (ch.Checked == true)
       {
           //database call here
       }
       else
       {
           //false database  call here
       }
   }


for any query and information comment or reply.
 
Share this answer
 
v3
Comments
joginder-banger 14-Dec-13 8:19am    
what's the problem guy's. plz any buddy tell me why the down vote of this answer. if authority want close this account sure i ready to close this account.
Richard MacCutchan 14-Dec-13 8:41am    
You probably got down voted because your answer does not address the question of how to store the checkbox value in the database.
joginder-banger 14-Dec-13 8:46am    
sir this is simple coding. sir I think this is working and understandable code.
Richard MacCutchan 14-Dec-13 9:02am    
It may be simple but it does not explain how to store the value in the database.
joginder-banger 14-Dec-13 9:06am    
sir I think know about how can save the data in database. this is not a real problem how can save the data in data base, Problem is How know Check box is checked or Not.

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