Export (0) Print
Expand All

ObjectDataSource::Deleting Event

Occurs before a Delete operation.

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

public:
 event ObjectDataSourceMethodEventHandler^ Deleting {
	void add (ObjectDataSourceMethodEventHandler^ value);
	void remove (ObjectDataSourceMethodEventHandler^ value);
}
<asp:ObjectDataSource OnDeleting="ObjectDataSourceMethodEventHandler" />

Handle the Deleting event to perform additional initialization that is specific to your application, to validate the values of parameters, or to change the parameter values before the ObjectDataSource control performs the delete operation. The parameters are available as an IDictionary collection that is accessed by the InputParameters property, which is exposed by the ObjectDataSourceMethodEventArgs object.

You can cancel the delete operation by setting the Cancel property of the ObjectDataSourceMethodEventArgs to true.

For more information about handling events, see Consuming Events.

This section contains two code examples. The first code example demonstrates how to use an ObjectDataSource object with a business object and a GridView control to delete data. The second code example shows the EmployeeLogic class that is used in the first code example.

The following code example demonstrates how to use an ObjectDataSource control with a business object and a GridView control to delete data. Initially, the GridView control displays a set of all employees, using the method that is specified by the SelectMethod property to retrieve the data from the EmployeeLogic object. Because the AutoGenerateDeleteButton property is set to true, the GridView control automatically displays a Delete button.

If you click the Delete button, the delete operation is performed using the method that is specified by the DeleteMethod property and any parameters that are specified in the DeleteParameters collection. In this code example, some preprocessing and post-processing steps are also performed. The NorthwindEmployeeDeleting delegate is called to handle the Deleting event before the operation is performed, and the NorthwindEmployeeDeleted delegate is called to handle the Deleted event after the operation has completed to perform exception handling. In this code example, if a NorthwindDataException is thrown, it is handled by the NorthwindEmployeeDeleted method.

No code example is currently available or this language may not be supported.

The following code example shows the EmployeeLogic class that is used in the preceding code example.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

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