I have been having some trouble loading the CheckBoxList with data. I have been getting some errors on the DisplayMember and ValueMember.
Here is my cod:.
Protected Sub LoadCBMembers(ByVal objDeptGUID As String)
Try
Dim myCBTable As New DataTable()
With myCBTable.Columns
.Add("DisplayName", GetType(String))
.Add("TextValue", GetType(String)) '<<<< change the type of this column to what you actually need instead of integer.
End With
Dim lqMembers As New lqFireFighterConnectDataContext
Dim GetMembers = From r In lqMembers.tbUsers
Where r.DeptGUID = objDeptGUID And r.TextFLag = True
Select r
If GetMembers.Count = 0 Then
Exit Sub
End If
For Each foundMember In GetMembers
myCBTable.Rows.Add(foundMember.FirstName & " " & foundMember.LastName, foundMember.CellPhone & "@" & foundMember.PhoneCarriers)
' cbMembers.Items.Add(foundMember.FirstName & " " & foundMember.LastName)
Next
With cbMembers
.DataSource = myCBTable
.DisplayMember = "DisplayName"
.ValueMember = "TextValue"
End With
Catch ex As Exception
End Try
End Sub
Try this:
According to the documentation, this method must be called explicitly. Not all controls require you to call
DataBind()explicitly (for many it is called for you implicitly), butCheckBoxListis an exception.