System.Web.UI.WebControls.SqlDataSource.Delete Method

Performs a delete operation using the SqlDataSource.DeleteCommand SQL string and any parameters that are in the SqlDataSource.DeleteParameters collection.

Syntax

public int Delete ()

Returns

A value that represents the number of rows deleted from the underlying database.

Remarks

Before the delete operation is performed, the SqlDataSourceView.OnDeleting(SqlDataSourceCommandEventArgs) method is called to raise the SqlDataSource.Deleting event. You can handle this event to examine the values of the parameters and to perform any preprocessing before a delete operation.

After the operation completes, the SqlDataSourceView.OnDeleted(SqlDataSourceStatusEventArgs) method is called to raise the SqlDataSource.Deleted event. You can handle this event to examine any return values and error codes and to perform any post-processing.

The SqlDataSource.Delete method is provided for programmatic access to the Delete method. If the System.Web.UI.WebControls.SqlDataSource control is associated with a data-bound control, the data-bound control automatically calls the Delete method.

The SqlDataSource.Delete method delegates to the erload:System.Web.UI.WebControls.SqlDataSourceView.Delete method of the System.Web.UI.WebControls.SqlDataSourceView object that is associated with the System.Web.UI.WebControls.SqlDataSource control. To perform the operation, the System.Web.UI.WebControls.SqlDataSourceView builds a System.Data.Common.DbCommand object using the SqlDataSource.DeleteCommand text and any associated SqlDataSource.DeleteParameters values, and then executes the System.Data.Common.DbCommand against the underlying database.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0