Quantcast
Channel: CSLA .NET
Viewing all articles
Browse latest Browse all 764

More Windows DataBinding Woes

$
0
0

Can anyone tell me where I am going wrong please...?

My problem relates to WinForms databinding and its relationship with a CSLA business object. In fact its CSLA business objects that in turn contain child collections that are really causing me trouble.

I fully understand about the need to disconnect the BO from the UI at the point I wish to cancel or revert changes. There are lots of examples in Rocky's book to demonstrate this. However to make for a pleasing user experience I need to invoke the following functionality.

1). Load the appropriate business object ( and its child collections ). The form obviously contains parent and child bindingsources.

2). Begin the edit.

3). Let the user make as may changes as they like to the BO and any of its child members.

4). Allow the user to save or revert ALL the changes made since the start of the edit session on the current BO. ( so I only want to be able to save/rollback at the parent level )

The only way that I can make this scenario work is to set DisableIEditableObject to true on both the parent and the child business objects. That way I have complete control over when BeginEdit(), ApplyEdit(), or CancelEdit() are called. If I dont do this for some reason the child edit levels get out of sync with the parent ( caused during child navigation via a datagrid no doubt ), and when I call CancelEdit() on the parent, it throws an exception.

I know Rocky says that setting DisableIEditableObject is the wrong road to take and he is ( as always ) right, as some of my bound windows components don't seem to update quite properly with this setting enabled. Surely I dont have to start drilling down into the children and calling CancelEdit() on each one of them do I ?

So, how do I control a save / undo process at the parent level only ?

Sorry if this is going over old ground, but I find windows databinding really frustrating! Crying

Thanks,

Nick


Viewing all articles
Browse latest Browse all 764

Trending Articles