SqlDataSource.Deleting Event


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Occurs before a delete operation.

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

member Deleting : IEvent<SqlDataSourceCommandEventHandler,

Handle the Deleting event to perform additional initialization operations that are specific to your application, to validate the values of parameters, or to change the parameter values before the SqlDataSource control performs the delete operation.

The connection to the underlying data source is not yet open when the event handler delegate is called. Therefore, you cannot cancel the operation directly by calling the Cancel method on the DbCommand object that is exposed by the SqlDataSourceCommandEventArgs object. You can, however, cancel the database operation by setting the Cancel property of the SqlDataSourceCommandEventArgs object to true.

For more information about handling events, see NIB: Consuming Events.

The following code example demonstrates how to handle the Deleting event that is raised before a Delete operation occurs. Because this example deletes data from the Northwind database, an OnDeleting handler is added to attempt to back up the database to disk before the Delete operation is performed.

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

.NET Framework
Available since 2.0
Return to top