Hi folks,
I'm a newbie having problems with binding tabledata to a ListBox.
Already searched the forum but didn't find a suitable solution.
This ist what I wanna have:
A ListBox filled with the "names"-column of my usertable. But if clicked on the name the corrosponding id should be returned. This is what my code looks like:
But in the ListBox it only shows entries displaying "System.Data.DataRowView".Code:Private Sub load_users() Dim ds As New DataSet() ds.Tables.Add(New DataTable("Users")) Dim da As SqlDataAdapter conn = New SqlConnection(myConnectString) conn.Open() da = New SqlDataAdapter("SELECT * FROM rmp_users ORDER BY LastName ASC", conn) da.Fill(ds, "Users") ListBox1.ValueMember = "id" ListBox1.DisplayMember = "LastName" ListBox1.DataSource = ds.Tables("Users") conn.Close() End Sub
Can anyone help me out with that? I have no clue.
Another question:
Can I put two columns into the ListBox1.DisplayMember (like "FirstName" + "LastName")?
Thanx for your help!
Tim




Reply With Quote