dragonfly
dragonfly

Reputation: 17773

ObjectDataSource - handle CRUD errors

What is the nice way of extending ObjectDataSource in order to handle CRUD errors. I know that there are events created, deleted, etc. that can have handlers that check e.Exception & e.ExceptionHandled, but I am not keen on repeating the same delegates over and over on all CRUD forms. I was thinking about inheriting from ObjectDataSource, any other ideas?

Thanks,Paweł

Upvotes: 1

Views: 166

Answers (1)

Magnus
Magnus

Reputation: 46947

That sound like a plan, and than internally subscribe to the events you need. Another way is to have a method that creates the ObjectDataSource (and subscribes to the events) that you use instead of creating it yourself.

public static ObjectDataSource CreateObjectDataSource()
{
   var obj = new ObjectDataSource();
   obj.Deleted  += OnDeleted; //function for handling event
   ...

   return obj;
}

Upvotes: 1

Related Questions