SHARE
TWEET

Untitled

Ortund Oct 26th, 2011 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ' 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.
  2.  
  3.     Private Sub GetOrgModules(ByVal OrganizationID As Integer)
  4.         ' Clear all currently selected modules for this Organization
  5.         Dim sql As String = "delete * from OrgModules where OrgID = " & OrganizationID
  6.         d.DoCommand(sql)
  7.  
  8.         sql = "select ModuleID, ModuleName from Modules"
  9.         Dim dr As SqlDataReader = d.GetReader(sql)
  10.  
  11.         chkModules.DataSource = dr
  12.         chkModules.DataTextField = "ModuleName"
  13.         chkModules.DataValueField = "ModuleID"
  14.         chkModules.DataBind()
  15.         dr.Close()
  16.  
  17.         sql = "select a.ModuleID, b.ModuleName from OrgModules as a" & vbCrLf & _
  18.             "inner join Modules as b on a.ModuleID = b.ModuleID" & vbCrLf & _
  19.             "where a.OrgID = " & OrganizationID
  20.         Dim drMod = d.GetReader(sql)
  21.         If drMod.HasRows Then
  22.             chkModules.ClearSelection()
  23.             While drMod.Read
  24.                 For i As Integer = 0 To chkModules.Items.Count - 1
  25.                     If chkModules.Items(i).Value = drMod.GetValue(0) Then
  26.                         chkModules.Items(i).Selected = True
  27.                         Exit For
  28.                     End If
  29.                 Next
  30.             End While
  31.             drMod.Close()
  32.         Else
  33.             drMod.Close()
  34.             chkModules.Visible = False
  35.         End If
  36.     End Sub
  37.  
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top