469,287 Members | 2,628 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,287 developers. It's quick & easy.

Problems on getting CheckBoxList selected Items

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

Nov 16 '05 #1
3 27223
Try this...

private void addToSelectedGroups()

{

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

{

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

}

}

bobc

"luisg" <lu*****@gmail.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
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

Nov 16 '05 #2


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

Luis

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #3
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[i].Selected)

{
if(!checkConference(cblConference.Items[i].Value))

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

iCounter = dtConference.Rows.Count-1;
dtConference.Rows[iCounter]["PersonID"]=sPersonID;
dtConference.Rows[iCounter]["Conference"]=cblConference.Items[i].Value.ToString();
dtConference.Rows[iCounter]["Notes"]=sPersonID;

}

}

"luisg" wrote:
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

Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by GTi | last post: by
1 post views Thread by Patrick Olurotimi Ige | last post: by
2 posts views Thread by John | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.