DataSourceView.ExecuteUpdate(IDictionary, IDictionary, IDictionary) 方法

定義

DataSourceView 物件表示的資料清單上,執行更新作業。Performs an update operation on the list of data that the DataSourceView object represents.

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

參數

keys
IDictionary

更新作業將更新的物件或資料列索引鍵 IDictionaryAn IDictionary of object or row keys to be updated by the update operation.

values
IDictionary

名稱/值組的 IDictionary,表示資料項目及其新值。An IDictionary of name/value pairs that represent data elements and their new values.

oldValues
IDictionary

名稱/值組的 IDictionary,表示資料項目及其原始值。An IDictionary of name/value pairs that represent data elements and their original values.

傳回

Int32

在基礎資料儲存區中更新的項目數目。The number of items that were updated in the underlying data storage.

例外狀況

範例

下列程式碼範例會示範擴充類別的類別如何覆 DataSourceViewCanUpdate 屬性和 ExecuteUpdate 方法。The following code example demonstrates how a class that extends the DataSourceView class can override the CanUpdate property and the ExecuteUpdate method. 這個程式碼範例是針對類別提供之較大範例的一部分 DataSourceViewThis code example is part of a larger example provided for the DataSourceView class.

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

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

End Class

備註

資料繫結控制項可以藉 ExecuteUpdate 由使用 DataSourceControl.GetView 方法來抓取 DataSourceView 物件並檢查屬性值,來判斷資料來源控制項是否支援此作業 CanUpdateData-bound controls can determine whether the ExecuteUpdate operation is supported by a data source control by using the DataSourceControl.GetView method to retrieve the DataSourceView object and checking the value of the CanUpdate property.

keys參數代表要更新之資料的物件或資料列索引鍵。The keys parameter represents the object or row keys of the data to update. 對於代表關聯式資料的資料來源(例如 SqlDataSource 控制項), keys 參數是資料庫主鍵的集合。For data sources that represent relational data, such as the SqlDataSource control, the keys parameter is a collection of database primary keys. 在其他情況下, keys 參數是名稱/值組的集合,用來篩選資料的清單。In other scenarios, the keys parameter is a collection of name/value pairs and is used to filter a list of data. 任何與名稱/值配對相符的資料都會以參數中找到的值進行更新 values ,這是一組名稱/值組,表示現有欄位或資料行的新值。Any data matching a name/value pair is updated with the values found in the values parameter, which is a set of name/value pairs that represents new values for existing fields or columns.

注意

DataSourceView類別的預設實作為擲回例外狀況 NotSupportedExceptionThe DataSourceView class's default implementation is to throw a NotSupportedException exception. 如果您擴充 DataSourceView 類別, ExecuteUpdate 如果您的類別支援更新基礎資料儲存體中的資料,請覆寫方法。If you extend the DataSourceView class, override the ExecuteUpdate method if your class supports updating data in the underlying data storage.

適用於

另請參閱