473,778 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4350
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.m icrosoft.com> wrote in
message news:A8******** *************** ***********@mic rosoft.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.DataSour ce = parent table;
combo1.DisplayM ember = col name from parent table;
combo1.ValueMem ber = col name from parent table;

combo2.DataSour ce = child table;
combo2.DisplayM ember = col name from child table;
combo2.ValueMem ber = col name from child table;
combo2.DataBind ings.Add("Selec tedValue", 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.SetDataBi nding(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.m icrosoft.com> wrote in
message news:A8******** *************** ***********@mic rosoft.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.co m

"da*******@opco .com" <da************ *@discussions.m icrosoft.com> wrote in
message news:AB******** *************** ***********@mic rosoft.com...
combo1.DataSour ce = parent table;
combo1.DisplayM ember = col name from parent table;
combo1.ValueMem ber = col name from parent table;

combo2.DataSour ce = child table;
combo2.DisplayM ember = col name from child table;
combo2.ValueMem ber = col name from child table;
combo2.DataBind ings.Add("Selec tedValue", 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.SetDataBi nding(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.m icrosoft.com> wrote in
message news:A8******** *************** ***********@mic rosoft.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.DataSour ce = DataSet.Relatio ns[name of relation];
combo2.DisplayM ember = col name from child table;
combo2.ValueMem ber = 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.co m

"da*******@opco .com" <da************ *@discussions.m icrosoft.com> wrote in
message news:AB******** *************** ***********@mic rosoft.com...
combo1.DataSour ce = parent table;
combo1.DisplayM ember = col name from parent table;
combo1.ValueMem ber = col name from parent table;

combo2.DataSour ce = child table;
combo2.DisplayM ember = col name from child table;
combo2.ValueMem ber = col name from child table;
combo2.DataBind ings.Add("Selec tedValue", 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.SetDataBi nding(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.m icrosoft.com> wrote in
message news:A8******** *************** ***********@mic rosoft.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.co m

"da*******@opco .com" <da************ *@discussions.m icrosoft.com> wrote in
message news:E0******** *************** ***********@mic rosoft.com...
No this does not work.

Here is what I try:
combo2.DataSour ce = DataSet.Relatio ns[name of relation];
combo2.DisplayM ember = col name from child table;
combo2.ValueMem ber = 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.co m

"da*******@opco .com" <da************ *@discussions.m icrosoft.com> wrote in
message news:AB******** *************** ***********@mic rosoft.com...
> combo1.DataSour ce = parent table;
> combo1.DisplayM ember = col name from parent table;
> combo1.ValueMem ber = col name from parent table;
>
> combo2.DataSour ce = child table;
> combo2.DisplayM ember = col name from child table;
> combo2.ValueMem ber = col name from child table;
> combo2.DataBind ings.Add("Selec tedValue", 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.SetDataBi nding(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.m icrosoft.com> wrote
>> in
>> message news:A8******** *************** ***********@mic rosoft.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
7686
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 different record, any changes in the current record are saved to an Access Database, the DataTable's Row Collection is Cleared and the New Record is read into the DataTable. (This is done to ensure that when the User goes to view a record, they get...
0
1523
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 other combobox. For reasons beyond the scope of this post I need to change the second comboboxe's selected index from within a ColumnChanging event handler. So, inside a ColumnChanging event handler I change the value of the column that is bound to...
1
6205
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"; this.cbxProductCategory.ValueMember = "PTCA_CODE"; to bind the data. Although I 'm 100% the data is inside the differnet DataTables.I don't see the values in the comboboxes. When I only bind one DataTable to one combobox
2
1915
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 its value after the textbox lost focus or whenever someone manually saved the record. I came to the conclusion after a long time and after many apps have been developed that there had to be a better way. What I thought would have been great is...
2
242
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 about how to data bind comboboxes so I can navigate through records. I have this working with text boxes already. My child dataset currently only contains data from 1 table with columns like eye_colour that are integers and refer to a lookup...
1
3624
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". Each combobox has its datasource, displaymember and SelectedValue member bound to separate tables thru individual datatsets thru individual data adapters. The two tables are "Class" and "SubClass". I use parameterized query to populate the...
4
6199
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 wrong information) I have verified the proper information through query analyzer.... Me.FormatName1ComboBox.DataSource = LabelFormats Me.FormatName1ComboBox.DisplayMember = "Formatname" Me.FormatName1ComboBox.ValueMember = "FormatName" ...
7
13531
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 this as the Value property binds correctly on it own. It is only when I bind the "Text" and "Value" that the issue occurs. The following sample code includes my custom classes and the Form Clode. I have several comboboxes and customer classes...
0
1314
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 creating these forms, I need to bind controls back to their underlying tables. This has been successful with textboxes, but I am having a lot of difficulty with comboboxes. Setting the datasource to the bindinglist seems to be ok, but I am having...
0
2290
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 combobox B. The combo boxes are bound to separate tables (e.g. state and city tables). For example, A might be State, and B might be City. Select a State, and the City list changes. I have gotten most of it done, but I have run into some snags. ...
0
9628
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
10292
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9923
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
8954
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...
1
7471
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6722
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
5368
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5497
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4031
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.