469,332 Members | 6,649 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,332 developers. It's quick & easy.

DataBinding for two comboboxes

Hi All:
I have a dataset contains two tables, one parent child relation between two
tables. I have no trouble to bind parent table to a combobox, relation to a
win grid control. But I am having trouble to bind relation into another combo
box. DotNet does not give me a run time error. But it did not perform the way
I am expecting.

Thanks in advance

DK

Nov 16 '05 #1
5 4183
DK,

Are you binding to the relation for the combobox as well? Can you show
some code, as well as what your expectations are?
"da*******@opco.com" <da*************@discussions.microsoft.com> wrote in
message news:A8**********************************@microsof t.com...
Hi All:
I have a dataset contains two tables, one parent child relation between
two
tables. I have no trouble to bind parent table to a combobox, relation to
a
win grid control. But I am having trouble to bind relation into another
combo
box. DotNet does not give me a run time error. But it did not perform the
way
I am expecting.

Thanks in advance

DK

Nov 16 '05 #2
combo1.DataSource = parent table;
combo1.DisplayMember = col name from parent table;
combo1.ValueMember = col name from parent table;

combo2.DataSource = child table;
combo2.DisplayMember = col name from child table;
combo2.ValueMember = col name from child table;
combo2.DataBindings.Add("SelectedValue", parent table, name of relation);

when the user changed value in combo1, the code should refresh data in combo2.
However, I can have other way around this issue. I just like to know I can
use relation to do this kind of binding, like I often do for Combox and
DataGrid (grid.SetDataBinding(parent table, name of relation)).

Thanks

"Nicholas Paldino [.NET/C# MVP]" wrote:
DK,

Are you binding to the relation for the combobox as well? Can you show
some code, as well as what your expectations are?
"da*******@opco.com" <da*************@discussions.microsoft.com> wrote in
message news:A8**********************************@microsof t.com...
Hi All:
I have a dataset contains two tables, one parent child relation between
two
tables. I have no trouble to bind parent table to a combobox, relation to
a
win grid control. But I am having trouble to bind relation into another
combo
box. DotNet does not give me a run time error. But it did not perform the
way
I am expecting.

Thanks in advance

DK


Nov 16 '05 #3
David,

Set the data source of combo2 to the relation itself, not to the child
table.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"da*******@opco.com" <da*************@discussions.microsoft.com> wrote in
message news:AB**********************************@microsof t.com...
combo1.DataSource = parent table;
combo1.DisplayMember = col name from parent table;
combo1.ValueMember = col name from parent table;

combo2.DataSource = child table;
combo2.DisplayMember = col name from child table;
combo2.ValueMember = col name from child table;
combo2.DataBindings.Add("SelectedValue", parent table, name of relation);

when the user changed value in combo1, the code should refresh data in
combo2.
However, I can have other way around this issue. I just like to know I can
use relation to do this kind of binding, like I often do for Combox and
DataGrid (grid.SetDataBinding(parent table, name of relation)).

Thanks

"Nicholas Paldino [.NET/C# MVP]" wrote:
DK,

Are you binding to the relation for the combobox as well? Can you
show
some code, as well as what your expectations are?
"da*******@opco.com" <da*************@discussions.microsoft.com> wrote in
message news:A8**********************************@microsof t.com...
> Hi All:
> I have a dataset contains two tables, one parent child relation between
> two
> tables. I have no trouble to bind parent table to a combobox, relation
> to
> a
> win grid control. But I am having trouble to bind relation into another
> combo
> box. DotNet does not give me a run time error. But it did not perform
> the
> way
> I am expecting.
>
> Thanks in advance
>
> DK
>


Nov 16 '05 #4
No this does not work.

Here is what I try:
combo2.DataSource = DataSet.Relations[name of relation];
combo2.DisplayMember = col name from child table;
combo2.ValueMember = col name from child table;

"Nicholas Paldino [.NET/C# MVP]" wrote:
David,

Set the data source of combo2 to the relation itself, not to the child
table.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"da*******@opco.com" <da*************@discussions.microsoft.com> wrote in
message news:AB**********************************@microsof t.com...
combo1.DataSource = parent table;
combo1.DisplayMember = col name from parent table;
combo1.ValueMember = col name from parent table;

combo2.DataSource = child table;
combo2.DisplayMember = col name from child table;
combo2.ValueMember = col name from child table;
combo2.DataBindings.Add("SelectedValue", parent table, name of relation);

when the user changed value in combo1, the code should refresh data in
combo2.
However, I can have other way around this issue. I just like to know I can
use relation to do this kind of binding, like I often do for Combox and
DataGrid (grid.SetDataBinding(parent table, name of relation)).

Thanks

"Nicholas Paldino [.NET/C# MVP]" wrote:
DK,

Are you binding to the relation for the combobox as well? Can you
show
some code, as well as what your expectations are?
"da*******@opco.com" <da*************@discussions.microsoft.com> wrote in
message news:A8**********************************@microsof t.com...
> Hi All:
> I have a dataset contains two tables, one parent child relation between
> two
> tables. I have no trouble to bind parent table to a combobox, relation
> to
> a
> win grid control. But I am having trouble to bind relation into another
> combo
> box. DotNet does not give me a run time error. But it did not perform
> the
> way
> I am expecting.
>
> Thanks in advance
>
> DK
>


Nov 16 '05 #5
David,

Does it throw an exception, or nothing happens?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"da*******@opco.com" <da*************@discussions.microsoft.com> wrote in
message news:E0**********************************@microsof t.com...
No this does not work.

Here is what I try:
combo2.DataSource = DataSet.Relations[name of relation];
combo2.DisplayMember = col name from child table;
combo2.ValueMember = col name from child table;

"Nicholas Paldino [.NET/C# MVP]" wrote:
David,

Set the data source of combo2 to the relation itself, not to the
child
table.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"da*******@opco.com" <da*************@discussions.microsoft.com> wrote in
message news:AB**********************************@microsof t.com...
> combo1.DataSource = parent table;
> combo1.DisplayMember = col name from parent table;
> combo1.ValueMember = col name from parent table;
>
> combo2.DataSource = child table;
> combo2.DisplayMember = col name from child table;
> combo2.ValueMember = col name from child table;
> combo2.DataBindings.Add("SelectedValue", parent table, name of
> relation);
>
> when the user changed value in combo1, the code should refresh data in
> combo2.
> However, I can have other way around this issue. I just like to know I
> can
> use relation to do this kind of binding, like I often do for Combox and
> DataGrid (grid.SetDataBinding(parent table, name of relation)).
>
> Thanks
>
> "Nicholas Paldino [.NET/C# MVP]" wrote:
>
>> DK,
>>
>> Are you binding to the relation for the combobox as well? Can you
>> show
>> some code, as well as what your expectations are?
>> "da*******@opco.com" <da*************@discussions.microsoft.com> wrote
>> in
>> message news:A8**********************************@microsof t.com...
>> > Hi All:
>> > I have a dataset contains two tables, one parent child relation
>> > between
>> > two
>> > tables. I have no trouble to bind parent table to a combobox,
>> > relation
>> > to
>> > a
>> > win grid control. But I am having trouble to bind relation into
>> > another
>> > combo
>> > box. DotNet does not give me a run time error. But it did not
>> > perform
>> > the
>> > way
>> > I am expecting.
>> >
>> > Thanks in advance
>> >
>> > DK
>> >
>>
>>
>>


Nov 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Timothy White | last post: by
reply views Thread by Richard | last post: by
1 post views Thread by Stijn Goris | last post: by
2 posts views Thread by Johann Blake | last post: by
2 posts views Thread by Jason and Cindy MacKenzie | last post: by
1 post views Thread by Gary Shell | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.