Redigera

Dela via


EntityDataSource.ContextDisposing Event

Definition

Occurs before an ObjectContext is disposed of.

public:
 event EventHandler<System::Web::UI::WebControls::EntityDataSourceContextDisposingEventArgs ^> ^ ContextDisposing;
public event EventHandler<System.Web.UI.WebControls.EntityDataSourceContextDisposingEventArgs> ContextDisposing;
member this.ContextDisposing : EventHandler<System.Web.UI.WebControls.EntityDataSourceContextDisposingEventArgs> 
Public Custom Event ContextDisposing As EventHandler(Of EntityDataSourceContextDisposingEventArgs) 

Event Type

Examples

To keep an existing ObjectContext instance member for future reference cancel the ContextCreated event as shown by the following code.

protected void EntityDataSource2_ContextDisposing(object sender,
    EntityDataSourceContextDisposingEventArgs e)
{
    e.Cancel = true;
}

Remarks

Handle this event to prevent the ObjectContext used by the EntityDataSource control from being disposed of. Do this when you want to use a single ObjectContext instance in your page with several controls or instances of the EntityDataSource control. To prevent the ObjectContext from being disposed of, set the Cancel property of the EntityDataSourceContextDisposingEventArgs object to true. For more information, see Object Context Life-Cycle Management (EntityDataSource). For more information about the object context, see Identity Resolution, State Management, and Change Tracking.

Applies to