DataBinding for two comboboxes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
DK,

Are you binding to the relation for the combobox as well? Can you show
some code, as well as what your expectations are?
 
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
 
David,

Set the data source of combo2 to the relation itself, not to the child
table.
 
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 said:
David,

Set the data source of combo2 to the relation itself, not to the child
table.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

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
 
David,

Does it throw an exception, or nothing happens?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

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 said:
David,

Set the data source of combo2 to the relation itself, not to the
child
table.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

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

:

DK,

Are you binding to the relation for the combobox as well? Can you
show
some code, as well as what your expectations are?
in
message 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
 
Back
Top