Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' The following code is meant to get a list of Modules specified by the user for the target organization and populate a CheckBoxList, showing the selected modules as Checked = True on their checkboxes.
- Private Sub GetOrgModules(ByVal OrganizationID As Integer)
- ' Clear all currently selected modules for this Organization
- Dim sql As String = "delete * from OrgModules where OrgID = " & OrganizationID
- d.DoCommand(sql)
- sql = "select ModuleID, ModuleName from Modules"
- Dim dr As SqlDataReader = d.GetReader(sql)
- chkModules.DataSource = dr
- chkModules.DataTextField = "ModuleName"
- chkModules.DataValueField = "ModuleID"
- chkModules.DataBind()
- dr.Close()
- sql = "select a.ModuleID, b.ModuleName from OrgModules as a" & vbCrLf & _
- "inner join Modules as b on a.ModuleID = b.ModuleID" & vbCrLf & _
- "where a.OrgID = " & OrganizationID
- Dim drMod = d.GetReader(sql)
- If drMod.HasRows Then
- chkModules.ClearSelection()
- While drMod.Read
- For i As Integer = 0 To chkModules.Items.Count - 1
- If chkModules.Items(i).Value = drMod.GetValue(0) Then
- chkModules.Items(i).Selected = True
- Exit For
- End If
- Next
- End While
- drMod.Close()
- Else
- drMod.Close()
- chkModules.Visible = False
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement