System.Web.UI.WebControls.ObjectDataSource.Delete Method

Performs a delete operation by calling the method that is identified by the ObjectDataSource.DeleteMethod property with any parameters that are in the ObjectDataSource.DeleteParameters collection.

Syntax

public int Delete ()

Returns

A value that represents the number of rows deleted from the underlying data storage, if the ObjectDataSourceStatusEventArgs.AffectedRows property of the System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs is set in the ObjectDataSource.Deleted event; otherwise, -1.

Remarks

Before the ObjectDataSource.Delete operation is performed, the ObjectDataSourceView.OnDeleting(ObjectDataSourceMethodEventArgs) method is called to raise the ObjectDataSource.Deleting event. You can handle the ObjectDataSource.Deleting event to examine the values of the parameters and to perform any preprocessing before a ObjectDataSource.Delete operation. To perform a delete operation, the System.Web.UI.WebControls.ObjectDataSourceView object uses reflection to create an instance of the object that is identified by the ObjectDataSource.TypeName property. It then calls the method that is identified by the ObjectDataSource.DeleteMethod property, using any associated ObjectDataSource.DeleteParameters properties. If the deletion parameters come from an associated data-bound control, the name of the parameters is created according to the ObjectDataSource.OldValuesParameterFormatString property. After the ObjectDataSource.Delete operation completes, the ObjectDataSourceView.OnDeleted(ObjectDataSourceStatusEventArgs) method is called to raise the ObjectDataSource.Deleted event. You can handle the ObjectDataSource.Deleted event to examine any return values, output parameters, and exceptions, and to perform any post-processing.

The ObjectDataSource.Delete method delegates to the ObjectDataSourceView.Delete(IDictionary, IDictionary) method of the System.Web.UI.WebControls.ObjectDataSourceView object that is associated with the System.Web.UI.WebControls.ObjectDataSource control.

Data-Bound Controls

When the System.Web.UI.WebControls.ObjectDataSource control is associated with a data-bound control, such as the System.Web.UI.WebControls.GridView control, it is not necessary to call the ObjectDataSource.Delete method from page code. The ObjectDataSource.Delete method is invoked directly by the data-bound control instead.

For more information about parameter merging, object lifetime, and method resolution, see ObjectDataSource.DeleteMethod.

Requirements

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