Hi,
I am also in an almost similar case. I have a root object with a child collection displayed with minimal editable properties in a grid in the main form. For detailed editing, i edit the items in the child collection in a dialog with the same scenario of commit/cancel the changes to the collection (CSLA 3.6.2). I also use a bindingNavigator to navigate and add/delete between the child items, which seems to work great.
What i did so far to get the thing (almost) working was
* In the constructor of the dialog
-> Passing the child collection to the dialog, which seems not to work, it passes the root object
-> To retrieve the child collection i reassign the datasource to the child collection who i get from drag and drop the collection from the data sources window
public FormBookDetail(BindingSource booksBindingSourceParent){
InitializeComponent();
// Set the current item in the parentlist to the current item in the detail panebooksBindingSource.DataSource = booksBindingSourceParent.DataSource;
booksBindingSource.DataMember =
"Books";booksBindingSource.Position = booksBindingSourceParent.Position;
// Populate the DataSource with the DropDown List datalanguageReadOnlyListBindingSource.DataSource =
LanguageReadOnlyList.FetchAll();bookTypeReadOnlyListBindingSource.DataSource =
BookTypeReadOnlyList.FetchAll();bookSubTypeReadOnlyListBindingSource.DataSource =
BookSubTypeReadOnlyList.FetchBookType(((Book)booksBindingSource.Current).BookTypeID); // Set the initial Read Write ControlreadWriteAuthorizationBook.ResetControlAuthorization();
}
* In the Closing event of the form
-> When i press apply, i close the dialog with calling .EndEdit() on the datasource in the dialog to avoid the 'Edit Level Mismatch in AcceptChanges' error when saving in the main form.
private void FormBookDetail_FormClosing(object sender, FormClosingEventArgs e){
booksBindingSource.EndEdit();
}
This works while editing 'simple' child collections who rely only on texboxes. However, when i use additional datasources to populate comboxes linked with the child object, it still gives me the 'Edit Level Mismatch in AcceptChanges' error.
Copyright (c) Marimer LLC