Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ASP.NET Checkbox List - How to read what was checked after submit

Posted on 2007-11-16
3
Medium Priority
?
1,006 Views
Last Modified: 2010-04-21
Hi Experts,

I have a dynamic checkbox list

<asp:CheckBoxList ID="CheckBoxList1" DataSource="<%# DataSet1.DefaultView %>" DataTextField="Description" DataValueField="ID" runat="server" RepeatDirection="Vertical" RepeatLayout="table"></asp:CheckBoxList>

Works great and displays correctly.

Once the user has checked the boxes they want, how do I read what was checked on the submitted page?

What I am trying to do is build a page that checks for available times in the database

Eg: The user may select Lesson1,Lesson2 and Lesson6
The resulting page will search the database for anything with those requirements and return a datagrid or repeater.

How do I know what boxes have been ticked so I can build my query.
Thanks a lot
Nik

0
Comment
Question by:nikdonovanau
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
digitalZo earned 2000 total points
ID: 20303608
VB Code [for multiple user selection]

http://authors.aspalliance.com/aspxtreme/webforms/controls/determiningselectioninlistcontrol.aspx

the selections are stored in the variable s. You can retrieve the data giving the WHERE clause using this variable and it will accordingly retrieve the data.


 Dim s As String = "Selected items:"
        For Each item As ListItem In CheckBoxList1.Items
            If item.Selected Then
                ' list the selected item
                s += item.Text + "<br>"
            End If
        Next
 
[SQL Query]

Open in new window

0
 
LVL 10

Expert Comment

by:digitalZo
ID: 20303625
0
 
LVL 1

Author Closing Comment

by:nikdonovanau
ID: 31409713
Thanks very much for that. Thats what I was after.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month20 days, 23 hours left to enroll

810 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