473,396 Members | 1,770 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,396 software developers and data experts.

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 4334
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Timothy White | last post by:
I have a Windows Form Which Displays one record at a time. The DataTable object which is bound to the Form Controls only contains the record that is being displayed. When I need to display a...
0
by: Richard | last post by:
Hi, I'm having issues with DataBinding. I have a Form with two data bound comboboxes on it. When you select something in one combobox I may {or may not} want to change the selected item in the...
1
by: Stijn Goris | last post by:
Hi all, I have 3 Comboboxes i want to bind with 3 different DatTables. I use this.cbxProductCategory.DataSource = myDataTable; this.cbxProductCategory.DisplayMember = "PTCA_DESCR";...
2
by: Johann Blake | last post by:
I've been playing around trying to bind textbox controls and datagrids to typed datasets. Up until recently, I never used DataBindings. I always manually wrote the value into a textbox and stored...
2
by: Jason and Cindy MacKenzie | last post by:
I have a simple windows forms app with databinding. Binding the textboxes with Me.TextBox1.DataBindings.Add("Text", Child1, "Child.ChildFirstName") seems quite straightforward. My question is...
1
by: Gary Shell | last post by:
I have a pair of combo boxes on a form. Both have their SelectedValue property bound to a column on a table called "Input_Output". One column is called "Class" and the second is called "SubClass"....
4
by: ECathell | last post by:
I am trying to databind 2 combo boxes to the same datasource but different fields using the same lookup table. The information in combobox2 is duplicating combobox 1(ie it appears to be gathering the...
7
by: JTC^..^ | last post by:
When i attempt to bind to the "Text" and "Value" property of a combobox on a windows form the value is reset when I leave the combobox. The comboboxes contain the correct Text and Values. I know...
0
by: theleshie | last post by:
Hi, I am creating an application which dynamically creates forms depending on the information held in a dataset (which also includes the data the application itself uses). As part of dynamically...
0
by: tschroeder250 | last post by:
Hello All, I am writing a form that allows maintenance of the fields of a table. Two of the controls on the form are comboboxes, where selecting a value in combobox A filters what appears in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
0
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...
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
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...
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,...

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.