Aug 24, 2009 01:54 AM|alok.arora|LINK
I assume you have this kind of a structure, (as per your query)
Now you have all user choices saved in tblUserChoices and table tblChoices is your Choice Master. so you need to first show up which choices are already selected by the user and insert new choices ticked by user.
for the same you may use this kind of a query.
Select UC.UserID, C.Details1 from tblUserChoices UC
RIGHT OUTER JOIN tblChoices C
ON C.ChoiceID = UC.ChoiceID
this will give you all the records from choice Master and if user have selceted that choice previously then it will show up userid against that else if user have not selected that previously you will have a null in the place of UserID.
depending on userid is null or not, you display a list of checkboxes marked as checked or unchecked and later if user checks some new choices you may insert the same into your DB.
let me know if you want to know the approach for insertion as well. you may do that without using any loop or multiple insert statements, just let me know if you need to know the approach!! ;)