Problem Pre Selecting CheckBoxes in a CheckBoxLis
Hi,
I am very new to asp.net, and programming in general. I am workig on an application for my department's website in which I have a long list of checkboxes set up under a CheckBoxList control. I need to be able to preselect some of these checkboxes based on an array list of id numbers that is retrieved from the database.
I have been successful in setting up the array and created this loop to compare each check box item to each value in the array, if a match is found between the checkbox's value and a value in the array then I need to have the checkbox checked.
However, this is only working for the first value in the array. If I have 5 values in the array (55, 88, 89, 91, 94) only checkbox "55" is checked. Can anyone help me please! I've been banging my head against the wall for three days to get this far :)
Dim i As Integer
Dim j As Integer
Dim Found As Boolean
For i = 0 To CheckBoxList1.Items.Count-1
For j = 0 To UBound(SpecSplit)
If cint(SpecSplit(j)) = CheckBoxList1.Items(i).Value Then
Found = True
Exit For
End IF
Next
If Found = True Then
CheckBoxList1.Items(i).Selected = "True"
Exit For
End If
Next
Thanks
Bret
Bret Sanders
|