从复选框列表中选择一个复选框后,我需要填充我的网格视图。我正在尝试使用循环,如果用户取消选中该复选框,我还需要隐藏网格视图。我使用 sql 语句来提取数据。sql 应该提取与复选框“显示来自选定类别受保护子 chkbListControl_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles chkListControl.SelectedIndexChanged 的书籍相关联的任何数据
Dim sqlChecked As String = "select * " _
& "from Books, Categories " _
& "where Categories.CategoryCode=Books.CategoryCode " _
& "order by Title;"
Dim sqlUnChecked As String = "select * from Books where Categories.CategoryCode=Books.CategoryCode;"
Dim selectedIndex As Integer = chkListControl.SelectedIndex
Dim i As Integer
If (selectedIndex <> -1) Then
For i = 0 To chkListControl.Items.Count - 1
If chkListControl.Items(i).Selected Then
gvwBookList.DataSource = ReturnTable(sqlChecked)
gvwBookList.DataBind()
Else
gvwBookList.DataSource = ReturnTable(sqlUnChecked)
gvwBookList.DataBind()
gvwBookList.Visible = False
End If
Next
End If
End Sub