Guest User

Untitled

a guest
Dec 13th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. Sub Populate(ByVal ComputerID As Integer)
  2. Dim ds As New DataTable
  3.  
  4. ds = FetchSoftware(ComputerID)
  5. ListBox1 = BindListBoxToTable(ListBox1, "tblSoftware", ds, "SoftwareName", "SoftwareID")
  6. End Sub
  7.  
  8.  
  9. Function FetchSoftware(ByVal ComputerID As Integer) As Schema.Computer.tblSoftwareDataTable
  10. Dim ds As Schema.Computer = New Schema.Computer
  11.  
  12. SqlHelper.FillDataset( _
  13. MyConnectionString, _
  14. "Software_SelectByComputerId", _
  15. ds, _
  16. New String() {"tblSoftware"}, _
  17. New Object() {ComputerID} _
  18. )
  19. Return ds.tblSoftware
  20. End Function
  21.  
  22.  
  23. Function BindListBoxToTable(ByVal LB As ListBox, ByVal TableName As String, _
  24. ByVal ds As DataTable, ByVal Field As String, ByVal ValueField As String) As ListBox
  25.  
  26. LB.DataMember = TableName
  27. LB.DataSource = ds
  28. LB.DataValueField = ValueField
  29. LB.DataTextField = Field
  30. LB.DataBind()
  31. Return LB
  32.  
  33. End Function
Add Comment
Please, Sign In to add comment