Export (0) Print
Expand All

EntityDataSource.Deleting Event

Occurs before an object is deleted from the data source.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web.Entity (in System.Web.Entity.dll)

public event EventHandler<EntityDataSourceChangingEventArgs> Deleting
<asp:EntityDataSource OnDeleting="EventHandler" />

The Deleting event is raised before the SaveChanges method is called on the ObjectContext to delete an object. The Entity property of the EntityDataSourceChangingEventArgs object is used to access the object to be deleted. The properties of this object may not be fully set. Only the properties required to identify the object must be set.

To stop the object from being deleted, set the Cancel property of the EntityDataSourceChangingEventArgs object to true.

If an error occurs when preparing to delete an object, the Deleting event is raised and the Exception property of the EntityDataSourceChangingEventArgs object is set to the returned Exception.

When you handle the exception in the Deleting event handler, set the ExceptionHandled property to true. This prevents the exception from being raised again. When you specify a value of false for the ExceptionHandled property, the EntityDataSource re-raises the exception.

.NET Framework

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft