|
-
Apr 23rd, 2008, 02:26 AM
#1
Thread Starter
New Member
[2003] ListBox DataSource problem
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:
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
But in the ListBox it only shows entries displaying "System.Data.DataRowView".
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
-
Apr 23rd, 2008, 03:14 AM
#2
Hyperactive Member
Re: [2003] ListBox DataSource problem
A listview might be more of your thing, it can display nice columns like in windows task manage.
-
Apr 28th, 2008, 08:59 AM
#3
Thread Starter
New Member
Re: [2003] ListBox DataSource problem
The column-thing is not that important. I need a method to get returned a userid after selecting a username. If that is possible with a listview - even better.
Tim
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|