Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

ObjectDataSource::Insert Method

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

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)
public:
int Insert()

Return Value

Type: System::Int32
A value that represents the number of rows inserted into the underlying data storage.

Before the Insert operation is performed, the OnInserting method is called to raise the Inserting event. You can handle the Inserting event to examine the values of the parameters and to perform any preprocessing before an Insert operation. To perform an insert operation, the ObjectDataSourceView object uses reflection to create an instance of the object that is identified by the TypeName property. It then calls the method that is identified by the InsertMethod property, using any associated InsertParameters properties. After the Insert operation completes, the OnInserted method is called to raise the Inserted event. You can handle the Inserted event to examine any return values, output parameters, and exceptions, and to perform any post-processing.

The Insert method delegates to the Insert method of the ObjectDataSourceView that is associated with the ObjectDataSource control.

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

Data-Bound Controls

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

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

Windows Phone 8.1, Windows Phone 8, 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.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.