Click here to Skip to main content
15,911,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all, I am a beginner c# programmer and need some help with a gridview. I have a gridview that has 3 edit templates...a textbox(default) a dropdownlist and a few checkboxes. In the database table there is a column thats datatype is tinyint. How when i need to update the database can i get the checkbox value if its checked then it gives one and if it isnt checked gives a 0.
Posted
Comments
pradiprenushe 18-Jul-12 7:43am    
You can do this requirement. But
I suggest you to set type of field must be bit which are used for textbox.

Hi,
Quote:
In the database table there is a column thats datatype is tinyint

Change the database column from tinyint to bit and send the boolean value
Quote:
1) true: if checkbox is checked
2) flase:if checkbox is not checked

from front-end. Your problem will be solved.

--Amit
 
Share this answer
 
Comments
Ruwaldo 18-Jul-12 7:54am    
Ok thanks will give it a try
Ruwaldo 18-Jul-12 8:24am    
I am not allowed to change the tables data types but found a solution.
String chk1 = ((System.Web.UI.WebControls.CheckBox)(row.Cells[4].Controls[1])).Checked ? "1" : "0";
this will return 1 if checked and 0 if it wasnt checked
 
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