System.Web.UI.WebControls.ObjectDataSource.Update Method

Performs an update operation by calling the method that is identified by the ObjectDataSource.UpdateMethod property and any parameters that are in the ObjectDataSource.UpdateParameters collection.

Syntax

public int Update ()

Returns

A value that represents the number of rows updated in the underlying data storage.

Remarks

The business object is assumed to update data one record at a time, rather than in a batch.

Before the ObjectDataSource.Update operation is performed, the ObjectDataSourceView.OnUpdating(ObjectDataSourceMethodEventArgs) method is called to raise the ObjectDataSource.Updating event. You can handle the ObjectDataSource.Updating event to examine the values of the parameters and to perform any preprocessing before an ObjectDataSource.Update operation. To perform an update operation, the System.Web.UI.WebControls.ObjectDataSourceView object uses reflection to create an instance of the object that is identified by the ObjectDataSource.TypeName property. It then calls the method that is identified by the ObjectDataSource.UpdateMethod property, using any associated ObjectDataSource.UpdateParameters properties. After the ObjectDataSource.Update operation completes, the ObjectDataSourceView.OnUpdated(ObjectDataSourceStatusEventArgs) method is called to raise the ObjectDataSource.Updated event. You can handle the ObjectDataSource.Updated event to examine any return values, output parameters, and exceptions, and to perform any post-processing.

The ObjectDataSource.Update method delegates to the ObjectDataSourceView.Update(IDictionary, IDictionary, IDictionary) method of the System.Web.UI.WebControls.ObjectDataSourceView that is associated with the System.Web.UI.WebControls.ObjectDataSource control.

For more information about parameter merging, object lifetime, and method resolution, see ObjectDataSource.UpdateMethod.

Note:

You should validate any parameter value that you receive from the client. The runtime simply substitutes the parameter value into the ObjectDataSource.UpdateMethod property.

Data-Bound Controls

When the System.Web.UI.WebControls.ObjectDataSource control is associated with a data-bound control, such as the System.Web.UI.WebControls.GridView control, it is not necessary to call the ObjectDataSource.Update method from page code. The ObjectDataSource.Update method is invoked directly by the data-bound control instead.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0