SqlDataSourceView::Update Method (IDictionary, IDictionary, IDictionary)
Performs an update operation using the UpdateCommand SQL string, any parameters that are in the UpdateParameters collection, and the values that are in the specified keys, values, and oldValues collections.
Assembly: System.Web (in System.Web.dll)
Parameters
- keys
- Type: System.Collections::IDictionary
An IDictionary of primary keys to use with the UpdateCommand property to perform the update database operation. If there are no keys associated with the query or if the UpdateCommand is not a parameterized SQL query, pass nullptr.
- values
- Type: System.Collections::IDictionary
An IDictionary of values to use with the UpdateCommand property to perform the update database operation. If there are no parameters associated with the query or if the UpdateCommand is not a parameterized SQL query, pass nullptr.
- oldValues
- Type: System.Collections::IDictionary
An IDictionary that represents the original values in the database. If there are no parameters associated with the query or if the UpdateCommand is not a parameterized SQL query, pass nullptr.
Return Value
Type: System::Int32A value that represents the number of rows updated in the underlying database.
| Exception | Condition |
|---|---|
| InvalidOperationException | The SqlDataSource cannot establish a connection with the underlying data source. |
| NotSupportedException | The CanUpdate property is false. |
The Update method calls the ExecuteUpdate method, passing the keys, values, and oldValues parameters. For more information, see SqlDataSource::UpdateCommand.
The following code example demonstrates how to use a SqlDataSource control to display data in a DropDownList control and update data when the Submit button is clicked. The UpdateCommand property is set with a parameterized SQL statement and two ControlParameter parameters are added to the UpdateParameters collection. When the Submit button is clicked, the OnClick event is handled to call the Update method explicitly.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.