See the remarks here for BindingList.AddNew.
http://msdn2.microsoft.com/en-us/library/ms132687(VS.80).aspx
You need to either have a public default constructor, which you don't normally have with CSLA, or handle the AddingNew event.
Overwrite OnAddingNew and in it create the new object and add it to the collection.
Cheers
Ross
See the remarks here for BindingList.AddNew.
http://msdn2.microsoft.com/en-us/library/ms132687(VS.80).aspx
You need to either have a public default constructor, which you don't normally have with CSLA, or handle the AddingNew event.
Overwrite OnAddingNew and in it create the new object and add it to the collection.
Cheers
Ross
Or even better, in your collection you can override AddNewCore(), where you create a new child, add it to the collection and return a reference to the new object. That, and setting AllowNew to true, is all you should have to do to enable in-place adding of new rows.
I have one question about this local creation of the objects. In the SimpleDataPortal.Create method you have a call that marks the object being created as New
MethodCaller.CallMethodIfImplemented(obj,
"MarkNew")Obviously, if I am not using the dataportal this method is not going to get called. Where would be the best place to mark the object as new when creating in this manner? Should it go in the override to AddNewCore?
Thanks
MarkNew should be called from inside the object itself. Even if
you don’t use the data portal, I recommend using a factory method, which
can make the call, or your constructor can make the call.
Realistically however, the only reason for calling MarkNew is to
ensure that IsDirty returns false. So you don’t need to call it on a new
object unless you set some properties (thus marking the object as dirty) during
its creation.
Rocky
From: DCottle
[mailto:cslanet@lhotka.net]
Sent: Thursday, May 17, 2007 1:15 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] Binding meltdown with 2.1.4
I have one question about this local creation of the objects. In the
SimpleDataPortal.Create method you have a call that marks the object being
created as New
MethodCaller.CallMethodIfImplemented(obj, "MarkNew")
Obviously, if I am not using the dataportal this method is not going to get
called. Where would be the best place to mark the object as new when
creating in this manner? Should it go in the override to AddNewCore?
Thanks
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.467 / Virus Database: 269.7.1/807 - Release Date: 5/16/2007 6:05
PM
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.467 / Virus Database: 269.7.1/807 - Release Date: 5/16/2007 6:05 PM
Copyright (c) Marimer LLC