basic deferred delete question

basic deferred delete question

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


akabak posted on Tuesday, August 15, 2006


I've got a web application that requires almost a two-part commit for all database saves. Basically what happens is I've got a multi-part form where each part can be edited individually and then a single save button that commits those edits to the database. Currently I'm just storing the edited business object in the session variable whenever it changes with an edit to any of the form parts and then saving that business object to the database when the user clicks the save button. It works correctly on all edits. I've got a cancel button that invalidates the session variable, reloads the object from the database, and rebinds all data controls. This works correctly as well.

My problem is how to handle the deletion of a child object from a bound grid? I understand that I have to implement deferred deletion somehow. I tried to overload the remove method to take an id of the child and then add that child to the deleted list instead of calling the remove (obj) method on the businesslistbase, but then it doesn't appear as deleted in the UI.

I know this is a basic question, and the answer is probably somewhere in the book (I'm using the C# 2005 version) or the sample code, but I can't find it. Any help would be greatly appreciated.


amanda

ajj3085 replied on Tuesday, August 15, 2006

Amanda,

The Remove( obj ) from BusinessListBase should provide the functionality already.  That method will remove the item from the list, and add it to the deletedList. 

Try using the Remove( obj ) method and see if that works; the reason your method is not is likely because you're not rasing any ListChanged events.

Your object will actually be deleted when you call Save on the subclass of BLB.

HTH
Andy

akabak replied on Tuesday, August 15, 2006

You're absolutely right. I was sure it was flowing all the way through to the deleteself method, but I was wrong. Thanks for your quick reply.

Copyright (c) Marimer LLC