473,406 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 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 2141
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Premkumar-Prem_kumar2003 | last post by:
Database details:- Four Categories r there. Every Category includes some Description. DATA BINDING FOR SELECTED INDEX CHANGED EVENT:- Req:- 1. Combobox 2. ListBox (or) Textbox (with multiline...
6
by: Brian Henry | last post by:
Here's an example of the code.. I have two combo boxes on screen that when one's selection is change the other's items will be updated to reflect the change (based on a relation) Private...
0
by: Larry Serflaten | last post by:
I am not sure how many are aware of this sort of data binding, but as it is new to many (classic) VB developers I thought I would post this once just to let people know of its availablility. ...
0
by: JSantora | last post by:
Essentially, InsertAT is broken! For the past couple of hours, I've been getting this "Parameter name: '-2147483550' is not a valid value for 'index'." error. Apparently, its caused by having...
0
by: oracle | last post by:
Greetings, I have a combo box that I binded to a data set using text and tags. I want it to display the DRT.Name property and have a DRT.UnitId as a value. ...
1
by: Monty M. | last post by:
Does anyone know how to perform two way data binding between a combo box and a listview. The listview is bound to a dataset table in code: Binding Bind = new Binding(); DataTable dt;...
3
by: Max | last post by:
Hello, I made a windows form with a combo box and 4 text boxes. All 5 objects should get their data from a data set which is populated in the form load method. The combo box has item ids. When...
10
by: =?Utf-8?B?UiBSZXllcw==?= | last post by:
Hi, Problem: How can I databind (or put) a SqlServer query's row return of 115,000 items into a ComboBox quickly? Not much longer than a matter of seconds, that is... Scenario: I am...
0
by: Dawnyy | last post by:
I have a form which is bound to a dataset. I am filling the forms dataset on Form_Load event. On my form I have combo boxes which I am setting by running a stored procedure to return a datatable,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.