Export (0) Print
Expand All

DataSourceView.ExecuteUpdate Method

Performs an update operation on the list of data that the DataSourceView object represents.

Namespace:  System.Web.UI
Assembly:  System.Web (in System.Web.dll)

protected virtual int ExecuteUpdate(
	IDictionary keys,
	IDictionary values,
	IDictionary oldValues
)

Parameters

keys
Type: System.Collections.IDictionary

An IDictionary of object or row keys to be updated by the update operation.

values
Type: System.Collections.IDictionary

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

oldValues
Type: System.Collections.IDictionary

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

Return Value

Type: System.Int32
The number of items that were updated in the underlying data storage.

ExceptionCondition
NotSupportedException

The ExecuteUpdate operation is not supported by the DataSourceView.

Data-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.

The keys parameter represents the object or row keys of the data to update. 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 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.

NoteNote

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

The following code example demonstrates how a class that extends the DataSourceView class can override the CanUpdate property and the ExecuteUpdate method. This 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();
}

.NET Framework

Supported in: 4.6, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft