System.Web.UI.WebControls.ObjectDataSource.Insert Method

Performs an insert operation by calling the method that is identified by the ObjectDataSource.InsertMethod property and any parameters in the ObjectDataSource.InsertParameters collection.

Syntax

public int Insert ()

Returns

A value that represents the number of rows inserted into the underlying data storage.

Remarks

Before the ObjectDataSource.Insert operation is performed, the ObjectDataSourceView.OnInserting(ObjectDataSourceMethodEventArgs) method is called to raise the ObjectDataSource.Inserting event. You can handle the ObjectDataSource.Inserting event to examine the values of the parameters and to perform any preprocessing before an ObjectDataSource.Insert operation. To perform an insert 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.InsertMethod property, using any associated ObjectDataSource.InsertParameters properties. After the ObjectDataSource.Insert operation completes, the ObjectDataSourceView.OnInserted(ObjectDataSourceStatusEventArgs) method is called to raise the ObjectDataSource.Inserted event. You can handle the ObjectDataSource.Inserted event to examine any return values, output parameters, and exceptions, and to perform any post-processing.

The ObjectDataSource.Insert method delegates to the ObjectDataSourceView.Insert(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.InsertMethod.

Data-Bound Controls

When the System.Web.UI.WebControls.ObjectDataSource object is associated with a data-bound control, such as the System.Web.UI.WebControls.GridView control, it is not necessary to call the ObjectDataSource.Insert method from page code. The ObjectDataSource.Insert 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