IsDirty turns TRUE after setting as datasource.

IsDirty turns TRUE after setting as datasource.

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


NelsonF posted on Monday, June 26, 2006

I can load my CSLA object into memory and everything is marked as "old" so IsDirty returns false on my root object immediatly after getting it.
 
The problem occurs when I bind an object to a BindingSource like so:
 
   propertyBindingSource.DataSource = _property;
 
The _property object becomes dirty immediately after the above code executes.
 
Is there a way to bind my CSLA object to a binding source without it going dirty on me?
 
Is there a way to know which property is being changed to make it dirty?
 
Thanks,
 
Nelson
 
 
 

cmellon replied on Tuesday, June 27, 2006

Hi Nelson,

The first thing I would check is that all your property setters compare the value before setting it.

Public Property Identification() As String

Get

Return mItemIdentification

End Get

Set(ByVal value As String)

If value <> mItemIdentification Then

mItemIdentification = value

MarkDirty()

End If

End Set

End Property

It may be that databinding is causing your property setters to be called, and if you don't have a check the value will be set and marked dirty, even if its the same value.

Just a thought, but I would check that first.

Craig

 

NelsonF replied on Tuesday, June 27, 2006

Thanks, its working now. It turns out a bound lookup combo was being updated from an change event in another control.

jh72i replied on Tuesday, June 27, 2006

Could be the same problem a lot of people are wrestling with - that the Binder (BindingContext/BindingManager - i can't remember) is actually calling AddNew on the fly to discover the full schema of your objects.

Do a search of the forum archive and you'll find some stuff.

Copyright (c) Marimer LLC