Click here to Skip to main content
15,895,283 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am having two checkboxes for two languages. If user checked both of them then how to save both checked values in one language column of table.
Posted
Comments
Karthik_Mahalingam 3-Dec-14 3:25am    
use comma separated value mechanism.

Simple answer is: YOU SHOULD NOT!

You should use additional table that will have foreign key on the main table and insert one or more rows into languages depending on the checkboxes. This is easily scalable (adding new languages changes only user interface), can be sorted, ordered, joined to other tables etc...

If you absolutely have to put them into single field, your best bet is comma separated list. Drawbacks of this severe: each time you have to access the field, you have to parse the values, you cannot search by it or order by it, you cannot join to other tables etc...

It would be better even to add a column separate for each language (also bad design, hope that you will never have to adapt to new language) then to put everything into single column.

If this helps please take time to accept the solution. Thank you.
 
Share this answer
 
Insert another row with another language selected or Store two checkbox values comma separated in column.
 
Share this answer
 
you can use some delimeters like '^' and save data.

ex;
data stored in db would be like this
lang1^lang2.


when you want to access those values you can split it like this

take the whole value into one variable called lang after that you can do the below coding

lang1= lang.Split('^').First;
lang2= lang.Split('^').Last;
 
Share this answer
 
Here you should use radio button or create another bit field in database i.e. one for English and another on for other language.
 
Share this answer
 
Comments
Thanks7872 3-Dec-14 2:18am    
Radio button is used you have only one option to be selected. Here, user can select two options also.

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