Solved

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

Posted on 2007-11-16
3
999 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 500 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

790 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