By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,651 Members | 1,908 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,651 IT Pros & Developers. It's quick & easy.

Dual combo box binding problem (with master detail relation)

P: n/a
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(dtMaster)

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

rel = New DataRelation("MasterDetail", dtMaster.Columns("Code"),
dtDetail.Columns("Code"))
ds.Relations.Add(rel)

cboMaster.DataSource = ds.Tables("Master")
cboMaster.DisplayMember = "Name"
cboMaster.ValueMember = "Code"

cboDetail.DataSource = ds.Tables("Detail")
cboDetail.DisplayMember = "Name"
cboDetail.ValueMember = "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
Share this Question
Share on Google+
5 Replies


P: n/a
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*******@yahoo.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(dtMaster)

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

rel = New DataRelation("MasterDetail", dtMaster.Columns("Code"),
dtDetail.Columns("Code"))
ds.Relations.Add(rel)

cboMaster.DataSource = ds.Tables("Master")
cboMaster.DisplayMember = "Name"
cboMaster.ValueMember = "Code"

cboDetail.DataSource = ds.Tables("Detail")
cboDetail.DisplayMember = "Name"
cboDetail.ValueMember = "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

P: n/a
dtMaster = ....
ds.Tables.Add(dtMaster)

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

rel = New DataRelation("MasterDetail", dtMaster.Columns("Code"),
dtDetail.Columns("Code"))
ds.Relations.Add(rel)

cboMaster.DataSource = ds.Tables("Master")
cboMaster.DisplayMember = "Name"
cboMaster.ValueMember = "Code"

cboDetail.DataSource = ds.Tables("Master")
cboDetail.DisplayMember = "MasterDetail.Name"
cboDetail.ValueMember = "Code"

Nov 21 '05 #3

P: n/a
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

P: n/a
Rulin Hong:
dtMaster = ....
ds.Tables.Add(dtMaster)

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

rel = New DataRelation("MasterDetail", dtMaster.Columns("Code"),
dtDetail.Columns("Code"))
ds.Relations.Add(rel)

cboMaster.DataSource = ds.Tables("Master")
cboMaster.DisplayMember = "Name"
cboMaster.ValueMember = "Code"

cboDetail.DataSource = ds.Tables("Master")
cboDetail.DisplayMember = "MasterDetail.Name"
cboDetail.ValueMember = "Code"


Thank for your reply, actually i prefer this method, but my combo box
show "System.Data.DataRowView" 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

P: n/a
Hi,

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

Ken
-------------------
"JC Voon" <jc*******@yahoo.com> wrote in message
news:41**************@msnews.microsoft.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 discussion thread is closed

Replies have been disabled for this discussion.