This documentation is archived and is not being maintained.

ObjectDataSourceView.ExecuteInsert Method

Note: This method is new in the .NET Framework version 2.0.

Performs an insert operation by calling the business object method that is identified by the InsertMethod property using the specified values collection.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

protected override int ExecuteInsert (
	IDictionary values
protected int ExecuteInsert (
	IDictionary values
protected override function ExecuteInsert (
	values : IDictionary
) : int



A IDictionary of parameters used with the InsertMethod property to perform the insert operation. If there are no parameters associated with the method, pass a null reference (Nothing in Visual Basic).

Return Value

The number of rows inserted; otherwise, -1, if the number is not known. For more information, see Insert.

Exception typeCondition


The CanInsert property returns false.

The ObjectDataSourceView class implements the inherited ExecuteInsert method to insert data into an underlying data store using a business object. Page developers and data-bound control authors do not call the ExecuteInsert method directly; instead, use the publicly exposed Insert method.

Before the insert is performed, the OnInserting method is called to raise the Inserting event. You can handle this event to examine the values of the parameters and perform any preprocessing before the Insert method is called.

To perform an insert operation, the ObjectDataSourceView control uses reflection to call the method that is identified by the InsertMethod property and any associated parameters that are in the values collection, and then executes it. After the operation completes, the OnInserted method is called to raise the Inserted event. You can handle this event to examine any return values, error codes, and perform any post-processing.

For more information on returning the number of rows inserted, see Insert.

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0