473,883 Members | 1,741 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Binding a ComboBox in a Windows Form to a Hierarchical DataSet

I have two tables in a parent-child relationship. Details on the tables are
as shown below:

Table1
-------
Item_ID (primary key)
Item_Owner (foreign key to Table2)

Table2
-------
Owner_ID (primary key)
Owner_Name
I wish to display, on a form designed for maintenance of the data in Table1,
a combobox which displays owner names (Table2.Owner_N ame), but returns as
its bound ValueMember the item owner's ID (Table1.Item_Ow ner). Can I do
it?

Thanks!

--
Greg Dunn

Nov 15 '05 #1
5 2606
Hi Greg,

AFAIK you can't. Binding is against flat table.
However, I am bit confused.
You want to show parent record name and return the child id?
Didn't you mean to display Owner_Name and return Owner_Id (as it is equeal
to Item_Owner)?

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

"Greg Dunn" <My*****@gregdu nn.com> wrote in message
news:SjmEb.4240 31$ao4.1359279@ attbi_s51...
I have two tables in a parent-child relationship. Details on the tables are as shown below:

Table1
-------
Item_ID (primary key)
Item_Owner (foreign key to Table2)

Table2
-------
Owner_ID (primary key)
Owner_Name
I wish to display, on a form designed for maintenance of the data in Table1, a combobox which displays owner names (Table2.Owner_N ame), but returns as
its bound ValueMember the item owner's ID (Table1.Item_Ow ner). Can I do
it?

Thanks!

--
Greg Dunn

Nov 15 '05 #2
> Didn't you mean to display Owner_Name and return Owner_Id (as it is equeal
to Item_Owner)?
Since, as you note, the Owner_ID will equal the Item_Owner, it really
doesn't matter which of them is returned. But Table1.Item_Own er is the
column to which I would like the control to be bound.
AFAIK you can't. Binding is against flat table.
I haven't found a way to do it, either. It seems like a nasty limitation,
though, since it forces me a choice among several things, none of which I
want to choose:

1. Foregoing the benefits of data binding in the form, or
2. Not using abstract primary keys, or
3. Denormalizing the database.

--
Greg Dunn
"Miha Markic" <miha at rthand com> wrote in message
news:eo******** ******@tk2msftn gp13.phx.gbl... Hi Greg,

AFAIK you can't. Binding is against flat table.
However, I am bit confused.
You want to show parent record name and return the child id?
Didn't you mean to display Owner_Name and return Owner_Id (as it is equeal
to Item_Owner)?

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

"Greg Dunn" <My*****@gregdu nn.com> wrote in message
news:SjmEb.4240 31$ao4.1359279@ attbi_s51...
I have two tables in a parent-child relationship. Details on the tables

are
as shown below:

Table1
-------
Item_ID (primary key)
Item_Owner (foreign key to Table2)

Table2
-------
Owner_ID (primary key)
Owner_Name
I wish to display, on a form designed for maintenance of the data in

Table1,
a combobox which displays owner names (Table2.Owner_N ame), but returns as its bound ValueMember the item owner's ID (Table1.Item_Ow ner). Can I do it?

Thanks!

--
Greg Dunn


Nov 15 '05 #3
Hi Greg,

Ah sorry, you are after a lookup, right.
Set ComboBox' ValueMamber and DisplayMember to a column from Table2 and
DataSource to Table2
Go to DataBindings and bind Selected Value to Table1.Item_Own er.

That should enable combobox to act like lookup.

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
"Greg Dunn" <My*****@gregdu nn.com> wrote in message
news:cbnEb.4243 04$ao4.1359496@ attbi_s51...
Didn't you mean to display Owner_Name and return Owner_Id (as it is equeal
to Item_Owner)?


Since, as you note, the Owner_ID will equal the Item_Owner, it really
doesn't matter which of them is returned. But Table1.Item_Own er is the
column to which I would like the control to be bound.
AFAIK you can't. Binding is against flat table.


I haven't found a way to do it, either. It seems like a nasty limitation,
though, since it forces me a choice among several things, none of which I
want to choose:

1. Foregoing the benefits of data binding in the form, or
2. Not using abstract primary keys, or
3. Denormalizing the database.

--
Greg Dunn
"Miha Markic" <miha at rthand com> wrote in message
news:eo******** ******@tk2msftn gp13.phx.gbl...
Hi Greg,

AFAIK you can't. Binding is against flat table.
However, I am bit confused.
You want to show parent record name and return the child id?
Didn't you mean to display Owner_Name and return Owner_Id (as it is equeal to Item_Owner)?

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

"Greg Dunn" <My*****@gregdu nn.com> wrote in message
news:SjmEb.4240 31$ao4.1359279@ attbi_s51...
I have two tables in a parent-child relationship. Details on the
tables are
as shown below:

Table1
-------
Item_ID (primary key)
Item_Owner (foreign key to Table2)

Table2
-------
Owner_ID (primary key)
Owner_Name
I wish to display, on a form designed for maintenance of the data in

Table1,
a combobox which displays owner names (Table2.Owner_N ame), but returns

as its bound ValueMember the item owner's ID (Table1.Item_Ow ner). Can I do it?

Thanks!

--
Greg Dunn



Nov 15 '05 #4
Greg,

You want to fill your Owner table with all the valid vlaues it would be
(complete table scan?) just use a Data Adapter to fill it or whatever you
want.

Then, on your bindings, you want to bind your combo boxes SelectedValue to
your Table1.Item_Own er Property.

This should take care of it.

and on yoru combo box, set your display member to Owner_name and your
valuemember to OwnerID. Thats all it takes.

peace,
cJ
"Greg Dunn" <My*****@gregdu nn.com> wrote in message
news:SjmEb.4240 31$ao4.1359279@ attbi_s51...
I have two tables in a parent-child relationship. Details on the tables are as shown below:

Table1
-------
Item_ID (primary key)
Item_Owner (foreign key to Table2)

Table2
-------
Owner_ID (primary key)
Owner_Name
I wish to display, on a form designed for maintenance of the data in Table1, a combobox which displays owner names (Table2.Owner_N ame), but returns as
its bound ValueMember the item owner's ID (Table1.Item_Ow ner). Can I do
it?

Thanks!

--
Greg Dunn

Nov 15 '05 #5
Ah...very easy. Many thanks!

--
Greg Dunn
"Miha Markic" <miha at rthand com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hi Greg,

Ah sorry, you are after a lookup, right.
Set ComboBox' ValueMamber and DisplayMember to a column from Table2 and
DataSource to Table2
Go to DataBindings and bind Selected Value to Table1.Item_Own er.

That should enable combobox to act like lookup.

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
"Greg Dunn" <My*****@gregdu nn.com> wrote in message
news:cbnEb.4243 04$ao4.1359496@ attbi_s51...
Didn't you mean to display Owner_Name and return Owner_Id (as it is equeal to Item_Owner)?


Since, as you note, the Owner_ID will equal the Item_Owner, it really
doesn't matter which of them is returned. But Table1.Item_Own er is the
column to which I would like the control to be bound.
AFAIK you can't. Binding is against flat table.


I haven't found a way to do it, either. It seems like a nasty limitation,
though, since it forces me a choice among several things, none of which I want to choose:

1. Foregoing the benefits of data binding in the form, or
2. Not using abstract primary keys, or
3. Denormalizing the database.

--
Greg Dunn
"Miha Markic" <miha at rthand com> wrote in message
news:eo******** ******@tk2msftn gp13.phx.gbl...
Hi Greg,

AFAIK you can't. Binding is against flat table.
However, I am bit confused.
You want to show parent record name and return the child id?
Didn't you mean to display Owner_Name and return Owner_Id (as it is equeal to Item_Owner)?

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

"Greg Dunn" <My*****@gregdu nn.com> wrote in message
news:SjmEb.4240 31$ao4.1359279@ attbi_s51...
> I have two tables in a parent-child relationship. Details on the tables are
> as shown below:
>
> Table1
> -------
> Item_ID (primary key)
> Item_Owner (foreign key to Table2)
>
> Table2
> -------
> Owner_ID (primary key)
> Owner_Name
>
>
> I wish to display, on a form designed for maintenance of the data in
Table1,
> a combobox which displays owner names (Table2.Owner_N ame), but

returns as
> its bound ValueMember the item owner's ID (Table1.Item_Ow ner). Can
I do
> it?
>
> Thanks!
>
> --
> Greg Dunn
>
>
>



Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
4344
by: Paul Slavin | last post by:
I have a textbox bound to a dataview, when I update the text in the textbox no changes take place in the underlying dataset. Why is this?? any answers appreciated, as to due to the underlying structure of the datasets, i.e lots of child tables etc, I cannot use bindingcontext
5
1603
by: Greg Dunn | last post by:
I have two tables in a parent-child relationship. Details on the tables are as shown below: Table1 ------- Item_ID (primary key) Item_Owner (foreign key to Table2) Table2 -------
1
2638
by: Bruce | last post by:
Hi, there, I meet a problem about comboBox binding. -------------------- Database: Northwind Tables: 1) Products 2) Categories I create a form (named "form1") to edit the record from Products table.
10
1924
by: Richard | last post by:
I have created a form which sets up a dataview. The form views one record at a time using a currencymanager. This works fine. All my text boxes bind. However I have a combo box which gets its lookup values from another (Advertising) table (AdvertisingID, Advertising). This works .. However, where it doesn't work as well is when the form loads, the combo boxes should bind to the AdvertisingID field and display the respective data.
4
4627
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box bound to a table as a lookup, drawing values from another table to populate the available selections. This all worked fine in VB6. I have distilled the problem down to a simple form drawing data from the Northwind database for a representative...
0
1575
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. this.drtComboBox.DataBindings.Add(new System.Windows.Forms.Binding("Tag", this.drtDataSet1, "DRT.UnitId")); this.drtComboBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.drtDataSet1, "DRT.Name"));
3
7536
by: Simon Tamman | last post by:
I've come across an interesting bug. I have workarounds but i'd like to know the root of the problem. I've stripped it down into a short file and hope someone might have an idea about what's going on. It's a simple program that loads a control onto a form and binds "Foo" against a combobox ("SelectedItem") for it's "Bar" property and a datetimepicker ("Value") for it's "DateTime" property. The DateTimePicker.Visible value is set to...
1
2240
by: Jim | last post by:
Hi, Trying to implement databinding. I've a dataset with a table, a windows form with typical controls: combobox, datetimepicker, textbox . . . I use what I think is a normal method to establish the bindings: textbox1.databindings.add("text", dataset, table.column) The records displays in the UI(if it exists). I can create an initial record and successfully save to the database.
1
2109
by: GS | last post by:
I am perplexed . I thought it is easy to fix the binding error on cvtDtFrom. I only used the cvtDtFrom a couple of places but I found out the error occurred before form loading. I tried searching in the solution for cvtDtFrom but failed to find the culprit. tried using clue from stack trace, searching for DataGridview and variations of view.datacon... no luck, Even tried searching all files for the sub main, I failed to find...
0
9942
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9792
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10743
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10847
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10416
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9574
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7129
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5991
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.