472,142 Members | 1,318 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,142 software developers and data experts.

Binding data to a Combo Box

Help me. I am obviously stupid! :-)
I am just starting out with VB.Net and am trying to do a simple master/detail form with a SqlServer backend.
I have created a combo box which is to populate with 'STATUS_DESC' from the STATUS table.
This works perfectly.
Now I want to populate the form with a row from the Purchase Order table
POHEADER and expect the combo box to get the 'STATUS_DESC' by looking up the STATUS table with POHEADER.STATUS_ID.
How come when I fill the dataset, the combo box gets the STATUS_ID instead?

I have the following values in the combo box properties:
DataSource: DsPurchaseOrder1.STATUS
DisplayMember: STATUS_DESC
ValueMember: STATUS_ID

In my book it talks about the 'SelectedValue' property but I can't seem to find that anywhere in the properties dialog.
Please help! How do i get it to lookup the description once it's retrieved the STATUS_ID from the Dataset?
THANKS!!
Nov 20 '05 #1
2 1994
What do you mean when you say the Combo box 'Gets' the STATUS_ID, do you
mean that is what is displayed ?

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"SoftWhiteDelgiht" <So**************@discussions.microsoft.com> wrote in
message news:79**********************************@microsof t.com...
Help me. I am obviously stupid! :-)
I am just starting out with VB.Net and am trying to do a simple master/detail form with a SqlServer backend. I have created a combo box which is to populate with 'STATUS_DESC' from the STATUS table. This works perfectly.
Now I want to populate the form with a row from the Purchase Order table
POHEADER and expect the combo box to get the 'STATUS_DESC' by looking up the STATUS table with POHEADER.STATUS_ID. How come when I fill the dataset, the combo box gets the STATUS_ID instead?
I have the following values in the combo box properties:
DataSource: DsPurchaseOrder1.STATUS
DisplayMember: STATUS_DESC
ValueMember: STATUS_ID

In my book it talks about the 'SelectedValue' property but I can't seem to find that anywhere in the properties dialog. Please help! How do i get it to lookup the description once it's retrieved the STATUS_ID from the Dataset?

THANKS!!

Nov 20 '05 #2
Hi Terry,
Yes, it displays the id instead of the description.
ie. When the screen first displays it populates the combo box with all the statuses. 'Approved', 'Closed' etc.
When I enter a Purchase Order number and fill the dataset, the Combo Box displays the number 5 and it is no longer populated with the statuses.
Here is the code:

Me.ComboBox1.DataBindings.Add(New System.Windows.Forms.Binding("Tag", Me.DsPurchaseOrder1, "POHEADER.PO_PONO"))
Me.ComboBox1.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.DsPurchaseOrder1, "POHEADER.PO_STATUS"))
Me.ComboBox1.DataBindings.Add(New System.Windows.Forms.Binding("SelectedValue", Me.DsPurchaseOrder1, "POHEADER.PO_STATUS"))
Me.ComboBox1.DataSource = Me.DsPurchaseOrder1.STATUS
Me.ComboBox1.DisplayMember = "STATUS_DESC"
Me.ComboBox1.Location = New System.Drawing.Point(464, 121)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(120, 21)
Me.ComboBox1.TabIndex = 63
Me.ComboBox1.Tag = ""
Me.ComboBox1.ValueMember = "STATUS_ID"

Thanks for your help.
Regards,
Marnie.

"One Handed Man ( OHM - Terry Burns )" wrote:
What do you mean when you say the Combo box 'Gets' the STATUS_ID, do you
mean that is what is displayed ?

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"SoftWhiteDelgiht" <So**************@discussions.microsoft.com> wrote in
message news:79**********************************@microsof t.com...
Help me. I am obviously stupid! :-)
I am just starting out with VB.Net and am trying to do a simple

master/detail form with a SqlServer backend.
I have created a combo box which is to populate with 'STATUS_DESC' from

the STATUS table.
This works perfectly.
Now I want to populate the form with a row from the Purchase Order table
POHEADER and expect the combo box to get the 'STATUS_DESC' by looking up

the STATUS table with POHEADER.STATUS_ID.
How come when I fill the dataset, the combo box gets the STATUS_ID

instead?

I have the following values in the combo box properties:
DataSource: DsPurchaseOrder1.STATUS
DisplayMember: STATUS_DESC
ValueMember: STATUS_ID

In my book it talks about the 'SelectedValue' property but I can't seem to

find that anywhere in the properties dialog.
Please help! How do i get it to lookup the description once it's retrieved

the STATUS_ID from the Dataset?


THANKS!!


Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Premkumar-Prem_kumar2003 | last post: by
reply views Thread by Larry Serflaten | last post: by
reply views Thread by oracle | last post: by
3 posts views Thread by Max | last post: by
10 posts views Thread by =?Utf-8?B?UiBSZXllcw==?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.