Problems on getting CheckBoxList selected Items

L

luisg

I am having some difficulty getting a checkboxlist control to determine

which checkboxes are checked. Here is a code sample from the event that
should read it:

private void addToSelectedGroups()
{
foreach(ListItem item in cblGroups.Items)
{
if (item.Selected)
{
// do something
}
}
}

The problem is that item.Selected is always false regardless of whether
the box is checked.


thanx

Luis
 
B

Bob Calvanese

Try this...

private void addToSelectedGroups()

{

for(int i = 0; i < this.cblGroups.CheckedItems.Count; i++)

{

MessageBox.Show("Item: " + this.cblGroups.CheckedItems.ToString() + " is
checked");

}

}

bobc
 
L

Luis Guzmá Hernández

Thanx bobc, but i forget to see i'm developing ASP.Net application and
haven't the CheckedListBox Control

Luis
 
G

Guest

cblConference it the check box list. This worked for me on an aspx page.

for(int i = 0; i<this.cblConference.Items.Count;i++)

{

if(cblConference.Items.Selected)

{


if(!checkConference(cblConference.Items.Value))

{


dtConference.Rows.Add(dtConference.NewRow());

iCounter = dtConference.Rows.Count-1;


dtConference.Rows[iCounter]["PersonID"]=sPersonID;


dtConference.Rows[iCounter]["Conference"]=cblConference.Items.Value.ToString();


dtConference.Rows[iCounter]["Notes"]=sPersonID;

}



}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top