|
-
Mar 19th, 2008, 08:16 AM
#1
Thread Starter
Addicted Member
[RESOLVED] ComboBox (Display, Value)
Hi,
I have a combo box where I populate manually from the database and using datareader.
From memory, in VB6 you could add the display value and the actual value, but in .NET there is not this option?
Anyway to get around this?
Thanks.
-
Mar 19th, 2008, 08:21 AM
#2
Re: ComboBox (Display, Value)
Don't populate the ComboBox manually from the DataReader. Use the DataReader to populate a DataTable and then bind that to the ComboBox. Problem solved.
vb.net Code:
Dim table As New DataTable table.Load(reader) reader.Close() myComboBox.DisplayMember = "Name" myComboBox.ValueMember = "ID" myComboBox.DataSource = table
-
Mar 19th, 2008, 08:53 AM
#3
Thread Starter
Addicted Member
Re: ComboBox (Display, Value)
Legend. Worked a treat. Thanks for that, and thank you for the quick response.
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
|