SqlDataSource.Deleting Event

Occurs before a delete operation.

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

member Deleting : IEvent<SqlDataSourceCommandEventHandler,
    SqlDataSourceCommandEventArgs>

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 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

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft