Click here to Skip to main content
15,920,111 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hii,
I want to know code of storing checkboxes value in one column and also how to retrieve them from database.Same applies for multiple radiobuttons.
Posted
Comments
Richard C Bishop 12-Mar-13 11:56am    
You collect the data, update the database, then query the database.

1 solution

If you want to store multiple checkbox values in a single column then you should turn the collection of checkboxes into a binary number

eg.
CHKBOX1 = 0
CHKBOX2 = 1
CHKBOX4 = 1
CHKBOX8 = 1

The number to store in the Db would then be 14 (i.e. 1*8 + 1*4 + 1*2 + 0*1)

To set the values from the database you need to reverse the process - i.e. take the number 14
get the binary representation and set the checkboxes appropriately.
 
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