DataBindingSyntaxAlternatives

This app illustrates how mismatches between the syntax style used to establish data binding and that used for record navigation within a form's CurrencyManager can cause data binding to work improperly.  

Statements that establish bindings specify both a dataSource and a dataMember.  But, in the presence of a strongly typed DataSet, the dataSource can be specified either as a simple DataSet name (e.g., objdsDataBinding) or as a DataTable qualified with a DataSet name (e.g., objdsDataBinding.Orders); and the dataMember can be specified either as a simple Column Name (OrderId), or as a ColumnName qualified with a DataTable name (Orders.OrderId). It thus becomes possible to set a binding to the same column of the same table of the same dataset using two difference syntaxes.  Whichever syntax you choose must be matched by the syntax you use in navigating the data using its CurrencyManager.

The form uses a parent-child relationship between an Orders table and an Order_Details_Extended table which is established in the dsDataBinding schema. When working properly, navigational controls on the form change the record position in the CurrencyManager for the parent (Orders) table, and the DataGrid displays corresponding records from the child (Order_Details_Extended) table.

Code in the form class utilizes the two different syntactical styles for filling the DataSet, setting up the data bindings, and navigating within the CurrencyManager.  You can perform the following experiments to see how mismatches between the syntaxes used for binding and record navigation can cause improper data binding behavior.  The experiments also show that the syntax used for the Fill operations doesn't matter, either in the success of the fills or in the data binding behavior.

Try these experiments in order:

1. Set the Fill, Binding, and Navigation styles to the syntactical alternative that specifies the objdsDataBinding DataSet as the dataSource. Note that data binding works properly:  the TextBox, Combobox, and DataGrid controls all track properly as the record position is changed using the navigation buttons.

2. Now set the Fill, Binding, and Navigation styles to the syntactical alternative that specifies the DataTable objdsDataBinding .Orders as the dataSource. Note that data binding again works properly in all respects.

Conclusion: Experiments 1 and 2 demonstrate that if *either* binding syntax is used consistently (for filling, binding, and navigation), data binding works properly.

3. Leaving the Binding and Navigation styles referencing DataTable objdsDataBinding .Orders, and change the Fill style to the one referencing the DataSet objdsDataBinding.  Note that data binding still works properly.

4. Change the Binding and Navigation styles to refer to objdsDataBinding, and change the Fill style to refer to objdsDataBinding .Orders.  Note that data binding again works properly.

Conclusion: Experiments 3 and 4 illustrate that the syntax style used for DataAdapter.Fill() operations does NOT have to be consistent with that used for data binding or list navigation.  This means that, for subsequent experiments, we can ignore the setting of the Fill style as irrelevant.

5. Set Navigation style to the one referencing objdsDataBinding .Orders and the Binding style to Mixed. Note that binding for the ComboBox control works, but bindings for the TextBox and DataGrid don't track with movement of the record pointer.  This is because in the Mixed binding style, only the binding for ComboBox is set using the syntax that refers to the DataTable, objdsDataBinding .Orders. The mismatch between the navigation syntax used on the CurrencyManager and the binding syntax used for the TextBox and DataGrid controls causes their data binding to work improperly.  There are two different CurrencyManagers involved, and the one being used for navigation isnt the same one that controls the bindings for the TextBox and DataGrid.

6. Leave the Binding style as Mixed, and change the Navigation style to refer to the DataSet objdsDataBinding. Note that now, binding for the TextBox and DataGrid controls works, but binding for the ComboBox doesn't track with movement of the record pointer.  This is flip side of the phenomenon observed in experiment 5.

Overall conclusion:  Make sure that the syntactical style you choose for navigation within a CurrencyManager matches the one you used for the data bindings you want to be controlled. You can do as you please with respect to DataAdapter.Fill() operations; however, I would suggest using one consistent syntax for all statements within any given form. This will reinforce the use of the style in your mind and the minds of other programmers who may work with the same code, avoiding downstream maintenance problems.
