Solved

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

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now