Removing isDirty, isDeleted, etc in a list item

Removing isDirty, isDeleted, etc in a list item

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


kucing posted on Tuesday, June 06, 2006

I want to move one of the items in the business base list, say the fifth item to index 0. I managed to do this by calling a procedure in the list object but the moved item is marked as dirty, savable and deleted. When I tried to remove the flag by calling item.IsDirty = false, the framework complained because it is read only. How can I clear those flags? Thanks.

ajj3085 replied on Wednesday, June 07, 2006

You aren't meant to change these flags manually.  The base class handles this. 

The flag IsDirty is correct because the item has changed since it was loaded from the database; namely it was marked for deletion.

Your object should know how to remove itself form the database and after the successful db operation, you should have the item call its MarkNew method.  This will properly mark the object to match its state in the db (New, and by definition, also dirty).  Normally you lose the reference to the deleted object though, but you don't necessarly have to.

HTH
Andy

RockfordLhotka replied on Wednesday, June 07, 2006

Variations on this have been discussed in other threads.

I really think the right answer for positional objects is to have the child object include a Position property and then to use a SortedBindingList to sort against that property. Don't actually try to put the child objects in specific positions in the list, but rather create a sorted view that shows them in specific positions based on the Position property.

kucing replied on Wednesday, June 07, 2006

Thanks.

However, it will be much nicer to have the control on changing those states....

Copyright (c) Marimer LLC