Gets or sets the name of the method or function that the ObjectDataSourceView object invokes to insert data.
Assembly: System.Web (in System.Web.dll)
The method that is identified by the property can be an instance method or a static (Shared in Visual Basic) method. If it is an instance method, the business object is created and destroyed each time the method specified by the property is called. You can handle the ObjectCreated event to work with the business object before the method specified by the property is called. You can also handle the ObjectDisposing event that is raised after the method specified by the property is called. (Dispose is called, only if the business object implements the IDisposable interface.) If the method is a static (Shared in Visual Basic) method, the business object is never created and you cannot handle these events.
If the business object that the ObjectDataSource object implements more than one method or function with the same name (method overloads), the data source control attempts to invoke the correct one according to a set of conditions, including the parameters in the InsertParameters collection. If the parameters in the InsertParameters collection do not match those of the method specified by the property signature, the data source throws an exception.
The value of the property is stored in view state.
For more information, see InsertMethod.
This section contains two code examples. The first code example demonstrates how to display filtered data using an ObjectDataSource control with a business object and a DetailsView control to insert data. The second code example provides an example of the middle-tier business object that is used in the first code example.
The following code example demonstrates how to use an ObjectDataSource control with a business object and a DetailsView control to insert data. The DetailsView initially displays a new NorthwindEmployee record, along with an automatically generated Insert button. After you enter data into the fields of the DetailsView control, click the Insert button. The property identifies which method performs the Insert operation.
In this code example, the UpdateEmployeeInfo method is used to perform an insert; however, it requires a NorthwindEmployee parameter to insert the data. For this reason, the collection of strings that the DetailsView control passes automatically is not sufficient. The NorthwindEmployeeInserting delegate is an ObjectDataSourceMethodEventHandler object that handles the Inserting event and enables you to manipulate the input parameters before the Insert operation proceeds. Because the UpdateEmployeeInfo method requires a NorthwindEmployee object as a parameter, one is created using the collection of strings and is added to the InputParameters collection using a parameter name (ne) that the method expects. You might perform steps like these when using an existing middle-tier object as a data source with types and methods that are not designed specifically for use with the ObjectDataSource control.
When the Insert operation is performed, the method that is identified by the property is called. If the Insert method of the object has a method signature that includes parameters, the InsertParameters collection must contain a parameter with names that match the method signature parameters for the Insert method to complete successfully.
The following code example provides an example of a middle-tier business object that the previous code example uses. The code example consists of two basic classes and an additional class:
The EmployeeLogic class is a stateless class, which encapsulates business logic.
The NorthwindEmployee class is a model class, which contains only the basic functionality that is required to load and persist data from the data tier.
An additional NorthwindDataException class is provided as a convenience.
For a complete working example, you must compile and use these classes. The UpdateEmployeeInfo method is not completely implemented, so you will not insert data into the Northwind Traders database when you experiment with this code example.
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)