Share via


DataSourceView.ExecuteDelete(IDictionary, IDictionary) 方法

定義

DataSourceView 物件表示的資料清單上,執行刪除作業。

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

參數

keys
IDictionary

IDictionary 作業將刪除的物件或資料列索引鍵 ExecuteDelete(IDictionary, IDictionary)

oldValues
IDictionary

名稱/值組的 IDictionary,表示資料項目及其原始值。

傳回

Int32

從基礎資料儲存區中刪除的項目數目。

例外狀況

範例

下列程式碼範例示範擴充 DataSourceView 類別的類別如何覆寫 CanDelete 屬性和 ExecuteDelete 方法。 此程式碼範例是針對 類別提供的較大範例的 DataSourceView 一部分。

// 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
   Get
      Return False
   End Get
End Property

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

備註

資料繫結控制項可以使用 方法來擷取 DataSourceView 物件 DataSourceControl.GetView ,並檢查 CanDelete 屬性,判斷資料來源控制項是否 ExecuteDelete 支援此作業。

參數 keys 代表要刪除之資料的物件或資料列索引鍵。 對於代表關聯式資料的資料來源,例如 SqlDataSource 控制項,參數 keys 是資料庫主鍵的集合。 在其他案例中 keys ,參數是名稱/值組的集合,可用來篩選資料清單。 刪除任何符合名稱/值組的資料。

注意

類別 DataSourceView 的預設實作是擲回 NotSupportedException 例外狀況。 如果您擴充 DataSourceView 類別,如果您的類別支援從基礎資料儲存體刪除,請覆寫 ExecuteDelete 方法。

適用於

另請參閱