How to bind mu开发者_如何学Cltiple tables to a binding navigator using data source wizard in C# so that when textbox1 value changes the values in other textboxes should be change which contains data from other table. tables have foreign key relationships.
The BindingNavigator should have a BindingSource value set to the BindingSource object of your "parent" or "master" table in the dataset (same as textBox1). The "other table" controls should have a BindingSource object that points to the "child" datatables. If your relationships are properly setup then when you change the master/parent record with the bindingnavigator then the detail/child records will update accordingly
Basically, the binding source for your "other tables" should have a DataSource value pointing to the BindingSource of your primary table (the binding source of textbox1) and should have a DataMember value of the relationship/FK that points to the respective secondary table.
If you are using drag and drop datasources then be sure you are dragging over the data sources that utilize the relationships. So say you created a dataset with 3 tables with tiered relationships: Grandparent, Parent, Child. In your Data Sources window you will see all three datatables side by side. You are probably dragging the desired Grandparent field over and getting your binding navigator, binding source, and textbox created, correct? You might think you are supposed to then use those side-by-side root-level Parent and Child datasources but that is WRONG. Expand the Grandparent source and at the end of columns listed you will see Parent listed again nested underneath Grandparent. Expand that and use those columns. At the bottom of that nested Parent you will see a Child data source that you can expand and use columns from.
精彩评论