DataGrid behavior
Form.Controls.Add of the DataGrid control (or of a control containing it) causes:
a. ListManager initialized.
b. Bound set to true.
c. BindingContext initialized to Form’s BindingContext.
d. IsHandleCreated still false.
e. DataBindings.Count still zero, this is independent of the BindingContext.
f. BindingContext collection has entries which are System.WeakReference’s to CurrencyManager or RelatedCurrencyManager objects. RCM’s extend CM’s. RCM’s have a parent reference to a CM.
a. “” is CurrencyManager for entire data set.
b. “job” is RelatedCurrencyManager.
g. grid.ListManager.GetHashCode() == grid.BindingContext[grid.DataSource, grid.DataMember].GetHashCode()
but
grid.ListManager != grid.BindingContext[grid.DataSource, grid.DataMember]
h. Form’s BindingContext == DataGrid.BindingContext
So far:
1. The AllowNew DataView property must be set true prior to a Clear-Fill load dataset operation. Failing to do so will cause the Grid to stop accepting new values for existing cells.
Comments
Probably the RelatedCurrencyManager tried to insert a new row to the parent records and that thrown an exception.
See my site for info.
Possible solution is
1. update parents and remember parents need deletion
2. update childs
3. delete parent and childs remembered in 1.
Posted by: NoiseEHC | October 27, 2004 10:43 AM