StrataFrame Forum

ChildForm BO Becomes Dirty Even though I havent changed anything

http://forum.strataframe.net/Topic22131.aspx

By Jon Neale - 2/28/2009

Hi,

I've created a form with a ListView and associated a child form used the business object translations to map the parent BO to the child BO. So far I've only got the edit bit working but you can go in and change the details and it all works ok.

I have a couple of issues which I'm stuggling with a bit:

I've added an Ok and Cancel button onto the child form but when I click the cancel it still asks me to save the changes. Looking at this further it seems the child form bo is dirty before we make any changes on the form. What would be causing this? Am I going about this in the correct way?

Also when I go back to my Parent form one of the other BO's seems to have been cleared out? Any hints on what this could be?

Thanks

Jon

By Edhy Rijo - 2/28/2009

Hi John,

Please take a look at the StrataFlix sample application which make heavy use of the ListView and then you can compare with your code.

Basically it will depend on the code you have in the Cancel/Ok buttons and where are you actually saving/undo the data, it could be at the childform or parent form level.  Also at the form the is a property named AutoShowSaveChanges which controls if the message will be shown when saving, but in your case I am sure you don't want to auto save the record, so if that is the case post your code for the OK/Cancel button and also check the StrataFlix code it will reveal many things.

By Jon Neale - 3/1/2009

Hi

Thanks for your reply.

I have compared what i've done against the stratflix sample and cant see anything obvious. I think I have two different problems one is that for some reason the bo of the childform is dirty without me making any changes on the form. I have seen a thread about datepickers causing issues so maybe need to look at this a bit more.

The other is the cancel button. I thought, and from the look of the Strataflix sample, the cancel button just drops you back to the parent form ignoring if any changes have taken place. I cant seem to get it to do this.

This is what I have in the Cancel Button click event:

DialogResult = System.Windows.Forms.DialogResult.Cancel;

I am only a newbie, just trialing the product, so its not the end of the world just like to know what I'm doing wrong.

Thanks again for your feedback.

Jon

 

By Jon Neale - 3/1/2009

I've managed to figure out part of it. The BO was being set to dirt as I had SetDirtyOnEdit = True on the BO. I'm not using a Maintenance Toolstrip so I think its ok to set this to false and everything seems to work ok now.

Thanks again

Jon

By Edhy Rijo - 3/1/2009

Hi Jon,

Glad you find the fix.  Now just to be clear, the StrataFlix approach of handling the data is not the same as the regular SF Maintenance Form would do, but it is a very good resource of seeing a different approach as one would call the standard/normal approach.

By Greg McGuffey - 3/2/2009

Jon, you may already know this, but just in case you don't and for those who may find this later...



Any time you have an unknow cause for a BO getting dirty, there is a handy event, the IsDirtyChanged event. Simply handle this event, set a break point in it, run code and then use the call stack to see were it is getting set dirty.



Glad you found your specific problem!