473,395 Members | 1,466 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 27408
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: GTi | last post by:
I have a listview that with selected items. But I want to "reselect" items after a refresh. Each items have a uniqe value in the Tag object. After a refresh some new items may be added or removed...
1
by: Peter | last post by:
How can I check which items has been selected in CheckBoxList control when I bind data to it from SQL Server? The code I use works fine when I add manually items into checkboxlist control, but does...
1
by: Patrick Olurotimi Ige | last post by:
I 'm databinding a CheckBoxList control Can somebody forward me a sample how to get if a checkBox is selected i want to return TRUE and if not FALSE? Thanks *** Sent via Developersdex...
1
by: Robin Tucker | last post by:
Hi ppl, My owner draw list box controls do not "refresh" old selected items when a new selection is made. This means that as you click to make selections, the previously selected items stay...
0
by: Brian Henry | last post by:
Since no one else knew how to do this I sat here all morning experimenting with this and this is what I came up with... Its an example of how to get a list of items back from a virtual mode list...
2
by: John | last post by:
I have a listbox that is databound when my form loads. A user can then select and option using a drop down box. When the user selects an option the corresponding items in the listbox gets selected....
2
by: K B | last post by:
Hi, The following code has been successful for me in the past and i just can't figure out where I'm going wrong. When I debug I keep getting the two top items as selected even though there are not...
1
by: TheDevelopers | last post by:
Hi All, I am using VB.NET 2005. I am using the control CheckedListBox control on my form, which is a collection of multiple check boxes. i am selecting multiple items from the collection and...
2
by: hmznzr | last post by:
i have a check list box. i am displaying the course names in that. user can check the courses they want to follow. they are allowed to select maximum of three courses. how can i get the checked...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.