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
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