473,804 Members | 3,010 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dual combo box binding problem (with master detail relation)

Hi:

I have two combo boxes on screen that when one's selection is change
the
other's items will be updated to reflect the
change

dtMaster = ....
ds.Tables.Add(d tMaster)

dtDetail = ...
ds.Tables.Add(d tBranch)

rel = New DataRelation("M asterDetail", dtMaster.Column s("Code"),
dtDetail.Column s("Code"))
ds.Relations.Ad d(rel)

cboMaster.DataS ource = ds.Tables("Mast er")
cboMaster.Displ ayMember = "Name"
cboMaster.Value Member = "Code"

cboDetail.DataS ource = ds.Tables("Deta il")
cboDetail.Displ ayMember = "Name"
cboDetail.Value Member = "Code"

Now, when the user changes the cboMaster, the cboDetail should show
only the record related to the cboMaster, but it show all !
How do i correct this?

Thanks
JCVoon
Nov 21 '05 #1
5 6314
Hi,

Bind the second combobox to a dataview. Filter the results for the
second combobox in the selected value changed event of the first combobox.

Ken
---------------
"JC Voon" <jc*******@yaho o.com> wrote in message
news:41******** *******@msnews. microsoft.com.. .
Hi:

I have two combo boxes on screen that when one's selection is change
the
other's items will be updated to reflect the
change

dtMaster = ....
ds.Tables.Add(d tMaster)

dtDetail = ...
ds.Tables.Add(d tBranch)

rel = New DataRelation("M asterDetail", dtMaster.Column s("Code"),
dtDetail.Column s("Code"))
ds.Relations.Ad d(rel)

cboMaster.DataS ource = ds.Tables("Mast er")
cboMaster.Displ ayMember = "Name"
cboMaster.Value Member = "Code"

cboDetail.DataS ource = ds.Tables("Deta il")
cboDetail.Displ ayMember = "Name"
cboDetail.Value Member = "Code"

Now, when the user changes the cboMaster, the cboDetail should show
only the record related to the cboMaster, but it show all !
How do i correct this?

Thanks
JCVoon
Nov 21 '05 #2
dtMaster = ....
ds.Tables.Add(d tMaster)

dtDetail = ...
ds.Tables.Add(d tBranch)

rel = New DataRelation("M asterDetail", dtMaster.Column s("Code"),
dtDetail.Column s("Code"))
ds.Relations.Ad d(rel)

cboMaster.DataS ource = ds.Tables("Mast er")
cboMaster.Displ ayMember = "Name"
cboMaster.Value Member = "Code"

cboDetail.DataS ource = ds.Tables("Mast er")
cboDetail.Displ ayMember = "MasterDetail.N ame"
cboDetail.Value Member = "Code"

Nov 21 '05 #3
Ken Tucker:
Bind the second combobox to a dataview. Filter the results for the
second combobox in the selected value changed event of the first combobox.


Thanks for the reply. It work for me now, but the DataRelation object
become useless, then what is the purposes of the DataRelation object
if we still need to do a lot of code to filter out the record ?

Cheers
JCVoon
Nov 21 '05 #4
Rulin Hong:
dtMaster = ....
ds.Tables.Add( dtMaster)

dtDetail = ...
ds.Tables.Add( dtBranch)

rel = New DataRelation("M asterDetail", dtMaster.Column s("Code"),
dtDetail.Colum ns("Code"))
ds.Relations.A dd(rel)

cboMaster.Data Source = ds.Tables("Mast er")
cboMaster.Disp layMember = "Name"
cboMaster.Valu eMember = "Code"

cboDetail.Data Source = ds.Tables("Mast er")
cboDetail.Disp layMember = "MasterDetail.N ame"
cboDetail.Valu eMember = "Code"


Thank for your reply, actually i prefer this method, but my combo box
show "System.Data.Da taRowView" in each record in the combo box,
instead of the column value, can u please tell me how to overcome this
problem ?

Thanks
JCVoon
Nov 21 '05 #5
Hi,

If you have 2 datagrids you can have a parent and child grid.

Ken
-------------------
"JC Voon" <jc*******@yaho o.com> wrote in message
news:41******** ******@msnews.m icrosoft.com...
Ken Tucker:
Bind the second combobox to a dataview. Filter the results for the
second combobox in the selected value changed event of the first combobox.


Thanks for the reply. It work for me now, but the DataRelation object
become useless, then what is the purposes of the DataRelation object
if we still need to do a lot of code to filter out the record ?

Cheers
JCVoon
Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
249
by: João Santa Bárbara | last post by:
Hi all i have a create a relation between two tables, and both of then have Autonumbers ( Sql ), since i have the Datarelation, i create a new record in the master table, and a few in the detail table. so far so good all work as i expected. ( when i create de details rows , all then have the key for the relation ) but when i do the update using my sqldataadapter like this Me.DataAdapter.Update(Tabela)
1
459
by: Juan | last post by:
I built a form that displays a master-detail relation ship, now i need to add a column to the datagrid displaying the master data, this column corresponds to the text name of a column stored in the master table as an integer (the foreign key, i need to display the text name of the foreign key stored in the third table). Do i have to create another datatable in the dataset im using that includes all the information I need? Change the Sql...
3
9951
by: Jane | last post by:
Hello, I am working on a windows application with C#. What I need is to display a list of data in 2nd combo box based on the selection of the 1st combo box. I used SqlCommand object and SqlDataReader. It works fine. But when I use DataAdapter and DataSet objects, it doesn't work. Here is my code. *********************************************************************************** In SQL db, there is a stored procedure: CREATE PROCEDURE ...
0
1217
by: sagdude | last post by:
I have a master detail datatable and add a relation DataRelation relation = new DataRelation("PartNoRelation", Dt_Cart.Columns, Tbl_NearestCenters.Columns,false); Ds_CartItem.Relations.Add(relation); when I try to add my detail to a radiobutton list in datalist(the master information are show in data list)I use this code but it shows all the data in detail table not just the related one private void DataList1_ItemDataBound(object sender,...
7
1521
by: erniej | last post by:
as per instructions in the walkthrough, I have managed to create a master/detail relationship between two datagrids. However I have a requirement to apply this to three datagrids and the third datagrid does not seem to reflect the selected row on the second datagrid using this method. The relevant lines of code are as follows. ' binding on master table dgTables.SetDataBinding(CurrentViewDS,"ALL_TABLES")
6
1633
by: Brian Henry | last post by:
Here's an example of the code.. I have two combo boxes on screen that when one's selection is change the other's items will be updated to reflect the change (based on a relation) Private ds_formData As New DataSet ' ' Fill Line Of Business ' cmd_selectCommand.CommandText = "BENESP_GetLinesOfBusiness" da_formData.FillSchema(ds_formData, SchemaType.Source, "LinesOfBusiness")
2
2162
by: SoftWhiteDelgiht | last post by:
Help me. I am obviously stupid! :-) I am just starting out with VB.Net and am trying to do a simple master/detail form with a SqlServer backend. I have created a combo box which is to populate with 'STATUS_DESC' from the STATUS table. This works perfectly. Now I want to populate the form with a row from the Purchase Order table POHEADER and expect the combo box to get the 'STATUS_DESC' by looking up the STATUS table with POHEADER.STATUS_ID....
4
1606
by: Patrick | last post by:
Hi - I have a master/detail form with a combo box (AssetCode) on the master form which uses a query as its Row Source. I can choose a selection from the AssetCode combo box which fires an AfterUpdate event to find the correct record and refresh the detail form. However- if I use the forward or back buttons the combo box it still lists the last lookup value. Is there a way that I can update the value in the combo box without firing the...
3
1877
by: fstenoughsnoopy | last post by:
Ok the complete story. I have a Contact Table, Query and Form, that are used to input and store the contact info for customers. They have FirstName, LastName and Address as the primary key fields to keep out duplicates. I am trying to put a full name box on the query, that uses the FirstName, LastName and Middle Initial and puts them together to form a full name. That I have so far. On my order database(consisting of a master table with...
0
9706
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
9579
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10578
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
10332
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10321
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9152
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...
0
6853
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
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4300
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.