Version

About Restoring Deleted Records

If you enable undo operations and record deletion, your end users can restore deleted records. However, unlike the other features that your end users can undo, you must implement the abstract UndeleteRecordsStrategy class to allow your end users to restore deleted records.

When you implement the UndeleteRecordsStrategy class, you must override the CanUndelete and Undelete methods.

  • CanUndelete - You can return a Boolean value to determine whether your end users can restore the deleted record(s).

  • Undelete - The RecordInfo objects that are passed into this method expose information about the deleted records. You can use this information to add/insert deleted data items back into the RecordManager object’s SourceItems collection. In addition, you must return a dictionary of RecordInfo objects mapped to the data items you inserted/added to the SourceItems collection. The mapping provides a way for the DataPresenter controls to undo changes that your end users applied to the record before deleting it.

After you implement the UndeleteRecordsStrategy class, you must handle a DataPresenter control’s RecordsDeleting event. In the event handler, set the RecordsDeletingEventArgs object’s UndeleteStrategy property to an instance of your class that implements the UndeleteRecordsStrategy class.

Implementing the UndeleteRecordsStrategy class is complex and may change based on your data source. Fortunately, the samples feature browser contains a sample named "Undo - Advanced" that demonstrates basic implementation of the UndeleteRecordsStrategy class that you can use as a starting point for your own implementation.