Issue with IsDirty after delete.

Issue with IsDirty after delete.

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


reagan123 posted on Wednesday, June 06, 2007

Hi everyone. I'll try to keep this brief.

I currently have a windows form that has a  combo box on it.. When the user selects a value, the objects values are loaded into text boxes on that form.

This all works great... when I delete the object, I call the delete, which works fine and then call a routine ClearForm() in which I set all of the text boxes to ""

My problem is that when I call ClearForm() it is setting IsDirty = true

Is there a way to clear out these text boxes without having IsDirty set to true?

Hope this makes sense!

Thanks for your time,
Shawn

Bowman74 replied on Wednesday, June 06, 2007

Shawn,

I'm assuming you are using data binding.  If you still have the text boxes bound to a CSLA object it is going to clear out the value in the CSLA object's property that the textbox is bound to when you set the textbox to "".  That's object's IsDirty value is now going to be True.  If you just want to clear out the textboxes and it is not valid to enter data into them I would remove the data bindings first so they won't try and update the object.  If you want to have an area where the use can enter new data then you should bind the text boxes to a new instance of the class not the old deleted instance.  That should set the textboxes values to be whatever the default values in your object are, most likely "" for strings without you having to do it explicitly.

Does this make sense or did I misunderstand you issue?

Thanks,

Kevin

Brian Criswell replied on Wednesday, June 06, 2007

Two different suggestions:
Finally, Iwould suggest that in general your code only modifies the business objects and not the controls that they are bound to.  It just generally works more predictably this way.

reagan123 replied on Wednesday, June 06, 2007

awesome guys!  thanks for the quick reply.  I'll go in and see which solution is the best for my situation.

As you can probably tell I'm really new to the framework.  I really like what I've seen so far, but still get confused on it at times.


Thanks again!

Brian Criswell replied on Wednesday, June 06, 2007

One thing I have noticed with people learning the framework is that the learning curve is fairly steep for a week or two.  But after a month or two of use, you realise that you know almost all of it quite well and are comfortable and productive.  The other thing is that you have a good community here with a very good signal to noise ratio.

Copyright (c) Marimer LLC