Help On Check Box list

Posted by Vijayar under C# on 12/16/2011 | Points: 10 | Views : 1277 | Status : [Member] | Replies : 1

I am a check box list to which i am binding the class names i e, first class,second class ----.I can select more than one class in check list box
I want to retrieve parent _id of each and every student of the classes selected from another table and save in another table

the new table structure is
Class Id,Parent Id.
How to do this by using loop when i select more than one class .Please help me with an attachment it's urgent



Posted by: muralikrishnasurap-12704 on: 12/16/2011 [Member] Starter | Points: 25

you can use foreach and get all the class id's from checkbox list in a string builder and get parents data from id's that you collected

Refer below code..

using System;

using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

public partial class CheckList : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)

protected void Button1_Click(object sender, EventArgs e)
StringBuilder _sb = new StringBuilder();
foreach (ListItem list in CheckBoxList1.Items)
Label1.Text = _sb.ToString();
catch (Exception ex)

Output: Label.Text=Id1,Id2,Id3,

Best Regards
Murali Krishna.S

Vijayar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response