Ortund Oct 26th, 2011 56 Never
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
- sql = "select ModuleID, ModuleName from Modules"
- Dim dr As SqlDataReader = d.GetReader(sql)
- chkModules.DataSource = dr
- chkModules.DataTextField = "ModuleName"
- chkModules.DataValueField = "ModuleID"
- 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
- 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
- End While
- chkModules.Visible = False
- End If
- End Sub
RAW Paste Data