Selecting multiple CheckBoxes in a CheckBoxList

R

Rick C

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)
frmStudentId.DataBind()
'
' 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
Else
frmStudentId.SelectedItem.Selected = False
End If
intIndex = intIndex + 1
Next

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top