Strange Problem Trying to Mark Object as 'Dirty'

Strange Problem Trying to Mark Object as 'Dirty'

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


Bonio posted on Sunday, September 10, 2006

This is really stumping me?? I have a C1 flexgrid bound to a Supplier object via a databinding source. I have a collection of SupplierContacts in the object and in the Supplier object. One of the fields of the SupplierContact object is boolean marked 'DefaultShipping'.

The flexgrid is bound to the SupplierContacts list and shows addresses plus the DefaultShipping as a checkbox. I need to enforce one rule for DefaultShipping - there must always be one and only one DefaultShipping checked in the list at one time. To achieve this rule, I wrote a loop in the 'set' part of the DefaultShipping that would reset other contacts if this particular contact had DefaultShipping set to true.

When I test it in the flexgrid, the property is called and the value is being set correctly  and being marked 'Dirty' (and I can see this in a 'watch'), however, after PropertyChanged as been called, the 'IsDirty' is reset to false and hence I cannot save?? I am using the latest version of CSLA 2 from Rocky's CVS.

Any ideas why this property won't stay dirty - I have not events etc attached,

 

Thanks

 

Bonio

 

Bonio replied on Sunday, September 10, 2006

As a follow-up, I think I have pinpointed the problem area:

When I initially load the form, I can edit the checkboxes on the flexgrid and the IsDirty flag is set and I can save. Following this first save though, the IsDirty flag is set when I change a checkbox but it appears to be reset prior to a save.

I have two flexgrids on the form - a SupplierContacts and a SupplierContactPhone (1:many rel). I have three databinding sources - the main SupplierEO one, one for SupplierContactList and one for SupplierContactPhoneList.

I use the Clone before Save method shown in Rocky's book - I have found that if I remove the clone bit and just save the object, there is no problem with the IsDirty flag (although I get an error with timestamps in my stored proc :( ) . If I use the Clone method, the IsDirty problem seems start after the first save on the object.

I will now proceed to bang my head against a wall until I find an answer :s

Bonio

RockfordLhotka replied on Sunday, September 10, 2006

Just guessing here, but I bet that data binding is calling CancelEdit on your object(s), thus resetting the dirty flag.

Bonio replied on Sunday, September 10, 2006

Hi Rocky,

Thanks for the reply.

How can I prevent the databinding calling CancelEdit??

Thanks again

Bonio

RockfordLhotka replied on Sunday, September 10, 2006

I don't know that you can - nor do I know if this is actually the problem - you need to confirm that this is what is happening before you can try to find a solution.
 
One possibility is that you might need to call EndEdit on the bindingsource or something along that line.
 
Rocky

Copyright (c) Marimer LLC