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_Name), but returns as
its bound ValueMember the item owner's ID (Table1.Item_Owner). Can I do
it?

Thanks!

--
Greg Dunn

Re: Binding a ComboBox in a Windows Form to a Hierarchical DataSet by Miha

Miha
Thu Dec 18 12:40:34 CST 2003

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" <MyLists@gregdunn.com> wrote in message
news:SjmEb.424031$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_Name), but returns as
> its bound ValueMember the item owner's ID (Table1.Item_Owner). Can I do
> it?
>
> Thanks!
>
> --
> Greg Dunn
>
>
>



Re: Binding a ComboBox in a Windows Form to a Hierarchical DataSet by Greg

Greg
Thu Dec 18 13:26:00 CST 2003

> 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_Owner 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:eodWtZZxDHA.3224@tk2msftngp13.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" <MyLists@gregdunn.com> wrote in message
> news:SjmEb.424031$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_Name), but returns
as
> > its bound ValueMember the item owner's ID (Table1.Item_Owner). Can I
do
> > it?
> >
> > Thanks!
> >
> > --
> > Greg Dunn
> >
> >
> >
>
>



Re: Binding a ComboBox in a Windows Form to a Hierarchical DataSet by Miha

Miha
Thu Dec 18 13:43:19 CST 2003

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_Owner.

That should enable combobox to act like lookup.

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


"Greg Dunn" <MyLists@gregdunn.com> wrote in message
news:cbnEb.424304$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_Owner 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:eodWtZZxDHA.3224@tk2msftngp13.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" <MyLists@gregdunn.com> wrote in message
> > news:SjmEb.424031$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_Name), but returns
> as
> > > its bound ValueMember the item owner's ID (Table1.Item_Owner). Can I
> do
> > > it?
> > >
> > > Thanks!
> > >
> > > --
> > > Greg Dunn
> > >
> > >
> > >
> >
> >
>
>



Re: Binding a ComboBox in a Windows Form to a Hierarchical DataSet by CJ

CJ
Thu Dec 18 14:09:11 CST 2003

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_Owner 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" <MyLists@gregdunn.com> wrote in message
news:SjmEb.424031$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_Name), but returns as
> its bound ValueMember the item owner's ID (Table1.Item_Owner). Can I do
> it?
>
> Thanks!
>
> --
> Greg Dunn
>
>
>



Re: Binding a ComboBox in a Windows Form to a Hierarchical DataSet by Greg

Greg
Thu Dec 18 14:18:04 CST 2003

Ah...very easy. Many thanks!

--
Greg Dunn


"Miha Markic" <miha at rthand com> wrote in message
news:%23v5Jx8ZxDHA.2408@tk2msftngp13.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_Owner.
>
> That should enable combobox to act like lookup.
>
> --
> Miha Markic - RightHand .NET consulting & development
> miha at rthand com
>
>
> "Greg Dunn" <MyLists@gregdunn.com> wrote in message
> news:cbnEb.424304$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_Owner 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:eodWtZZxDHA.3224@tk2msftngp13.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" <MyLists@gregdunn.com> wrote in message
> > > news:SjmEb.424031$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_Name), but
returns
> > as
> > > > its bound ValueMember the item owner's ID (Table1.Item_Owner). Can
I
> > do
> > > > it?
> > > >
> > > > Thanks!
> > > >
> > > > --
> > > > Greg Dunn
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>