BeginEdit, ApplyEdit and CancelEdit?

BeginEdit, ApplyEdit and CancelEdit?

Old forum URL: forums.lhotka.net/forums/t/3947.aspx


CSLAer posted on Wednesday, November 28, 2007

Hi Rock,

You mentioned if a BO is bind to control, we try not to use bo.BeginEdit, bo.ApplyEdit and bo.CancelEdit directly. Instead we should use bindingsource to do that. I find your PTWin in 2.x is using this way, while in 3.x, you are actually using bo.BeginEdit, bo.ApplyEdit and bo.CancelEdit directly. Is any reason to do so?

RockfordLhotka replied on Wednesday, November 28, 2007

The specific rule is that you should never call the *Edit() methods on the business object while it is data bound to a bindingsource.

If you read the data binding chapter in the Using CSLA .NET 3.0 ebook, I discuss how the PTWin code works in some detail. The explicit calls in PTWin are there to support the Cancel button on the forms, but notice that the *Edit() methods are only called when the object is not data bound to a bindingsource.

Copyright (c) Marimer LLC