Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Selecting multiple CheckBoxes in a CheckBoxList

Thread Tools

Selecting multiple CheckBoxes in a CheckBoxList

Rick C
Posts: n/a
I am having trouble selecting multiple checkboxes in a checkboxlist. The code below will select the last checkbox, if the data base value indicates it should be checked. The code will also de-select (uncheck) any prior checkboxes in the checkboxlist. I am using Microsoft Visual Studio 2003 (with VB):

My aspx code:

<asp:CheckBoxList id="frmStudentId" DataValueField="SchoolStudentId" DataTextField="wrkName" Runat="server" Font-Bold=True></asp:CheckBoxList>

My VB code:

Protected WithEvents frmStudentId As system.Web.UI.WebControls.CheckBoxList
' Bind the data to the checkboxlist
frmStudentId.DataSource = objSchoolStudent.GetSchoolStudent("AllByDesc", CInt(Session("wrkSchoolId")), 1, CInt(Session("wrkStudentId")), 1)
' Now go back and set the check marks based on what is on file
intIndex = 0
Dim liCountP As ListItem
For Each liCountP In frmStudentId.Items
frmStudentId.SelectedIndex = intIndex
If objSchoolStudent.GetSchoolStudent("Solo", 1, 1, 1, CInt(frmStudentId.SelectedItem.Value)) = "Y" Then
frmStudentId.SelectedItem.Selected = True
frmStudentId.SelectedItem.Selected = False
End If
intIndex = intIndex + 1

The dll works ok to retrieve the data (referenced above as "objSchoolStudent.GetSchoolStudent"). The data bind works fine.. I see the text of all appropriate check boxes. In debug all variables appear OK and stepping through the logic indicates the above If statement is true multiple times (and "frmStudentId.SelectedItem.Selected = True" is executed correctly multiple times).

Any suggestion is appreciated. Thanks, Rick
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting multiple checkboxes inside a GridView control Mark B ASP .Net 3 03-30-2009 01:19 AM
Help selecting multiple checkboxes based on partial value JL Javascript 7 03-10-2008 01:10 AM
Help: Using Multiple Checkboxes in a Checkboxlist to filter results in a gridview in ASP.NET 2.0 joebob8000 ASP .Net 0 12-04-2006 07:54 PM
Help: Using Multiple Checkboxes or Checkboxlist to filter results in a gridview in ASP.NET 2.0 / VS2005 ASP .Net 0 12-29-2005 11:43 PM
Selecting multiple checkboxes with a single checkbox. Eric Javascript 1 10-24-2003 07:33 PM