Export (0) Print
Expand All

ObjectDataSourceView::InsertParameters Property

Gets the parameters collection that contains the parameters that are used by the InsertMethod method.

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

public:
property ParameterCollection^ InsertParameters {
	ParameterCollection^ get ();
}

Property Value

Type: System.Web.UI.WebControls::ParameterCollection
A ParameterCollection that contains the parameters used by the InsertMethod property.

The names and types of the parameters that are contained in the InsertParameters collection must match the names and types of the parameters that are in the method specified by the InsertMethod property signature. When working with data-bound controls that supply parameters, such as GridView and DetailsView, the ObjectDataSource control automatically merges any parameters that are explicitly specified in the collection with those parameters that are provided by the data-bound control. 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 implementation of the Insert method 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 InsertMethod property identifies which method performs the Insert operation.

If you click the Insert button, the Insert operation is performed using the method that is specified by the InsertMethod property and any parameters that are specified in the InsertParameters collection. In this code example, one parameter is specified in the InsertParameters collection that corresponds to the supervisor's ID. This is because even though the ID is displayed in the Fields collection for the DetailsView control as a BoundField object, it will be passed as a string to the ObjectDataSource control. By adding it explicitly to the InsertParameters collection with a Type property that is set to the Int32 value, it will be passed correctly by the ObjectDataSource to the method as an int, not as string.

When the Insert operation is performed, the method that is identified by the InsertMethod 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 to complete successfully.

No code example is currently available or this language may not be supported.

The following code example provides an example implementation of the Insert method that the preceding code example uses. The InsertNewEmployeeWrapper method is added to the EmployeeLogic middle-tier object to enable the object to work more easily with the ObjectDataSource control in Web scenarios, without a substantial rewrite to the actual business logic.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0
Show:
© 2015 Microsoft