Solved

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

Posted on 2007-11-16
3
1,000 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…

697 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