Solved

ASP.net ListBox with check boxes

Posted on 2011-02-14
4
1,051 Views
Last Modified: 2012-06-27
Hi

In ASP.net 4 is there a ListBox control that contains check boxes within it?
How would I gather which items have been checked using VB.net.
I'd like to gather bith the index and the accompanying label
0
Comment
Question by:murbro
  • 2
4 Comments
 
LVL 10

Expert Comment

by:John Claes
ID: 34886712
as Far as I remember the ListBox has a property Items.
Herein you'll find all Checkboxes.

You can loop through them by indexCounter
if checked ==> you have the index and the checkbox (so also the lable)

Regards
Poor Beggar
0
 
LVL 7

Accepted Solution

by:
mr_nadger earned 500 total points
ID: 34895796
Use the CheckBoxList object, then iterate through the items list, I think the properties you want are:
i as the index (Starting at 0)
CheckBoxList.Items(i).Selected (=true or false)
CheckBoxList.Items(i).Text

Alternatively, if going from an onclick event, you have
CheckBoxList.SelectedIndex
CheckBoxList.SelectedItem.Text
CheckBoxList.SelectedItem.Selected


0
 
LVL 7

Expert Comment

by:mr_nadger
ID: 34895820
oh, if you're going to remove items from the list programmatically, iterate backwards through the list to avoid index out of range errors
0
 

Author Closing Comment

by:murbro
ID: 34914920
thanks very much
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question