Click here to Skip to main content
15,891,976 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have student management system i want to select multiple subjects for one student to insert in database using checked box list control.... plz give quick solution with code...
Posted
Comments
Prasad Avunoori 21-May-14 23:30pm    
Pass those values as comma separated to the database. In database split them and insert.

just use for looop that will check how many checkbox in a checkbox list are clicked after that write your insert code in side for loop
C#
for(int i=0;i<checkboxlist1.items.count,i++)>
{
//your insertion code goes hear
}
 
Share this answer
 
v2
Comments
Sanjay K. Gupta 22-May-14 0:47am    
The code is fine but add condition for getting selected list items only. If it is a window app then there is a property called "SelectedItems".
Awadhendra Tripathi 22-May-14 0:48am    
yes thats fine please refer this also
Sanjay K. Gupta 22-May-14 0:50am    
Then please Improve your solution so that OP can accept your answer and may be helpful to others in future.
C#
 foreach (ListItem list in CheckBoxList1.Items)
        {
            if (list.Selected == true)
            { 

//your Insert Query
            
            }
        }
 
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