Export (0) Print
Expand All

EntityDataSource.Updating Event

Occurs before changes to an object are persisted to the data source.

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

member Updating : IEvent<EventHandler<EntityDataSourceChangingEventArgs>,
    EntityDataSourceChangingEventArgs>
<asp:EntityDataSource OnUpdating="EventHandler" />

The Updating event is raised before changes to the properties of an object are persisted to the data source. The Updating event enables you to modify or verify changes to the object, supply a different object, or cancel the operation before the changes are persisted. You can access the modified object from the Entity property of the EntityDataSourceChangingEventArgs object. If supplying a different object, the user is responsible for setting the correct entity type in the Entity property.

Handle the Updating event if you must modify the ObjectStateEntry for the object to set different original values for concurrency control. For more information, see Saving Changes and Managing Concurrency (Entity Framework).

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

If an error occurs when instantiating an object or modifying properties, the Updating event is raised and the Exception property of the EntityDataSourceChangingEventArgs object is set to the returned Exception.

When you handle the exception in the Updating 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.5.2, 4.5.1, 4.5, 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft