Selecting multiple CheckBoxes in a CheckBoxList

Discussion in 'ASP .Net Web Controls' started by Rick C, Jun 29, 2004.

  1. Rick C

    Rick C Guest

    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
     
    Rick C, Jun 29, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    5,603
  2. joebob8000
    Replies:
    0
    Views:
    1,092
    joebob8000
    Dec 4, 2006
  3. Mark B
    Replies:
    3
    Views:
    2,743
    Mark B
    Mar 30, 2009
  4. Eric
    Replies:
    1
    Views:
    165
  5. JL
    Replies:
    7
    Views:
    209
    Thomas 'PointedEars' Lahn
    Mar 10, 2008
Loading...

Share This Page