checkboxlist - 2 Part Question
I have a listbox populated with Users and a checkboxlist that is filled with report numbers.
Once a person clicks on a User i'm wanting the corresponding reports to be checked in the checkboxlist.
i know how to fill the checkboxlist but i dont know how to check the boxes once a user is selected.
Code:
OpenDataSet(dsBound, "SELECT BlockerNum FROM tblSQLReports ORDER BY BlockerNum ASC", "tblSQLReports")
chkFields.DataSource = dsBound.Tables("tblSQLReports")
chkFields.DataTextField = "BlockerNum"
chkFields.DataValueField = "BlockerNumID"
chkFields.DataBind()
Re: checkboxlist - 2 Part Question [Resolved]
i got it...
Code:
Private Sub lstUsers2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstUsers2.SelectedIndexChanged
Dim strSQL As String
Dim x As Integer
' fill report list
strSQL = "SELECT BlockerNum FROM tblSQLReports where userid='" & lstUsers2.SelectedValue & "' ORDER BY BlockerNum ASC"
dsData.Clear()
OpenDataSet(dsData, strSQL, "tblSQLReports")
x = 0
Dim i As Integer
Try
starthere:
For i = 0 To chkFields.Items.Count - 1
If chkFields.Items(i).Text = dsData.Tables("tblSQLReports").Rows(x).Item("BlockerNum") Then
'if current checkbox contains value, select the box
chkFields.Items(i).Selected = True
End If
Next
x = x + 1
GoTo starthere
Catch ex As Exception
End Try
End Sub