Occurs before the object that is identified by the ObjectDataSource.TypeName property is discarded.
The ObjectDataSource.ObjectDisposing event is always raised before the instance of the business object is discarded. If the business object implements the IDisposable interface, the IDisposable.Dispose method is called after this event is raised.
Handle the ObjectDataSource.ObjectDisposing event to call other methods on the object, set properties, or perform clean-up that is specific to the object before the object is destroyed. A reference to the object is accessed by the ObjectDataSourceEventArgs.ObjectInstance property, which is exposed by the System.Web.UI.WebControls.ObjectDataSourceEventArgs object.
When you use a System.Web.UI.WebControls.ObjectDataSource control with a LINQ to SQL class, you must cancel the disposing of the data-context class in an handler for the ObjectDataSource.ObjectDisposing event. This step is necessary because LINQ to SQL supports deferred execution, whereas the System.Web.UI.WebControls.ObjectDataSource control tries to dispose the data context after the Select operation.
For more information about how to handle events, see Consuming Events.