BlakeMcKenna
asked on
Trying to load a ComboBox using a DataTable?
I have a simple procedure in which I'm trying to assign a DataSource to a ComboBox DataSource. When I look at how many rows were added to the DataSource, the count is correct, however, when I go to select an entry from the ComboBox, all the entry values are "System.Data.DataRowView". Not sure what is causing this. Here is my code:
Private Sub LoadNewUsersComboBox()
Try
Dim tbl As New DataTable
Dim row As DataRow
tbl.Columns.Add("commonName")
tbl.Columns.Add("SAMAccountName")
For x As Integer = 0 To arrStcLDAP.Count - 1
row = tbl.NewRow
row("commonName") = arrStcLDAP(x).commonName
row("SAMAccountName") = arrStcLDAP(x).samAcctName
tbl.Rows.Add(row)
Next
cmbUserName.DataSource = Nothing
cmbUserName.DisplayMember = tbl.Columns(0).ColumnName.ToString
cmbUserName.ValueMember = tbl.Columns(1).ColumnName.ToString
cmbUserName.DataSource = tbl
cmbUserName.SelectedIndex = -1
Catch ex As Exception
EH.ErrorMessage = "LoadNewUsersComboBox() - " & ex.Message & "~E"
End Try
EH.ProcessMessages(Me, sbr, EH.ErrorMessage)
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I found my own problem!
Open in new window