DataSourceView.ExecuteDelete(IDictionary, IDictionary) Method


Performs a delete operation on the list of data that the DataSourceView object represents.

 virtual int ExecuteDelete(System::Collections::IDictionary ^ keys, System::Collections::IDictionary ^ oldValues);
protected virtual int ExecuteDelete (System.Collections.IDictionary keys, System.Collections.IDictionary oldValues);
abstract member ExecuteDelete : System.Collections.IDictionary * System.Collections.IDictionary -> int
override this.ExecuteDelete : System.Collections.IDictionary * System.Collections.IDictionary -> int
Protected Overridable Function ExecuteDelete (keys As IDictionary, oldValues As IDictionary) As Integer



An IDictionary of object or row keys to be deleted by the ExecuteDelete(IDictionary, IDictionary) operation.


An IDictionary of name/value pairs that represent data elements and their original values.



The number of items that were deleted from the underlying data storage.



The following code example demonstrates how a class that extends the DataSourceView class can override the CanDelete property and the ExecuteDelete method. This code example is part of a larger example provided for the DataSourceView class.

// The CsvDataSourceView does not currently
// permit deletion. You can modify or extend
// this sample to do so.
public override bool CanDelete {
    get {
        return false;
protected override int ExecuteDelete(IDictionary keys, IDictionary values)
    throw new NotSupportedException();
' The CsvDataSourceView does not currently
' permit deletion. You can modify or extend
' this sample to do so.
Public Overrides ReadOnly Property CanDelete() As Boolean
      Return False
   End Get
End Property

Protected Overrides Function ExecuteDelete(keys As IDictionary, values As IDictionary) As Integer
   Throw New NotSupportedException()
End Function 'ExecuteDelete


Data-bound controls can determine whether the ExecuteDelete operation is supported by a data source control by retrieving the DataSourceView object using the DataSourceControl.GetView method, and checking the CanDelete property.

The keys parameter represents the object or row keys of the data to delete. For data sources that represent relational data, such as the SqlDataSource control, the keys parameter is a collection of database primary keys. In other scenarios, the keys parameter is a collection of name/value pairs and is used to filter a list of data. Any data matching a name/value pair is deleted.


The DataSourceView class's default implementation is to throw a NotSupportedException exception. If you extend the DataSourceView class, override the ExecuteDelete method if your class supports deletion from the underlying data storage.

Applies to

See also