Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / October 2005

Tip: Looking for answers? Try searching our database.

databinding to two comboboxes through dataset relationship

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robin - 14 Sep 2005 23:59 GMT
I have two combo boxes that are populated and bound from two related dataset
tables through their relationship, like this:

//bind to domain tables to populate values
ParentComboBox.DataSource = myDataSet.ParentTable;
ParentComboBox.DisplayMember = "Name";
ParentComboBox.ValueMember = "NameID";

ChildComboBox.DataSource = myDataSet.ParentTable;
ChildComboBox.DisplayMember = "ChildParentRelationship.ChildName";
ChildComboBox.ValueMember = "ChildParentRelationship.ChildNameID";

//bind to a different dataset table where value will be saved...
ParentComboBox.DataBindings.Add("SelectedValue", _dataSource, _dataMember +
".ParentID");
ChildComboBox.DataBindings.Add("SelectedValue", _dataSource, _dataMember +
".ChildID");

This code automatically filters the second (child) combo box when the parent
combo box value is changed, because of the dataset relationship. The problem
is that, the child value does not get saved or even recognized through
binding. I can't even endcurrentedit manually, but no event gets fired when
the second combo box changes through this binding method (ValueMemberChanged
for example).

The value of the second combo box only saves when you manually select it. The
user would need to manually select a value from the second combobox every
time, even if the correct one is shown when the parent combo box is changed.
Please provide a solution. thanks.
"Jeffrey Tan[MSFT]" - 05 Oct 2005 08:55 GMT
Hi robinne123,

Thanks for your post.

No, I do not think we can save the selected value in combobox in this way.
Because the ComboBox.SelectedValue is populated by complex databinding, we
can not use another simple databinding to save it value in another
datasource.

To save the selected value, we can hook ComboBox's SelectedIndexChanged
event and save the current selected value in this event.

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.