Export (0) Print
Expand All

ObjectDataSource::DeleteParameters Property

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

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

[PersistenceModeAttribute(PersistenceMode::InnerProperty)]
public:
property ParameterCollection^ DeleteParameters {
	ParameterCollection^ get ();
}

Property Value

Type: System.Web.UI.WebControls::ParameterCollection
A ParameterCollection that contains the parameters used by the DeleteMethod method.

The names and types of the parameters that are contained in the DeleteParameters collection must match the names and types of the parameters in the DeleteMethod method signature. The parameter names are affected by the OldValuesParameterFormatString property and are case-sensitive. The parameters in the collection depend on the data that is in the data-bound control, the parameters that are specified declaratively, and the parameters that are added programmatically. For more information, see "Parameter Merging" in Delete and Using Parameters with the ObjectDataSource Control.

The DeleteParameters property retrieves the DeleteParameters property that is contained by the ObjectDataSourceView object that is associated with the ObjectDataSource control.

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

This section contains two code examples. The first code example demonstrates how to use an ObjectDataSource object with a business object and a GridView control to delete data. The second code example shows the EmployeeLogic class that is used in the first code example.

The following code example demonstrates how to use the DeleteParameters property of the ObjectDataSource control with a business object and a GridView control to delete data. Initially, the GridView control displays a set of all employees, using the method that is specified by the SelectMethod property to retrieve the data from the EmployeeLogic object. Because the AutoGenerateDeleteButton property is set to true, the GridView control automatically displays a Delete button.

If you click the Delete button, the Deleting event is called with two parameters. One parameter, EmpID, comes from the DataGrid control, and is based on the DataKeyNames property. The other parameter comes from the declarative DeleteParameters property. The EmployeeLogic class overloads the DeleteEmployee method. One overload takes a NorthwindEmployee parameter, and the other takes an Int32 parameter named anID. In the Deleting event, the entries in the InputParameters property are adjusted to include only one parameter named anID with the value from original_EmpID. When the event handler exists, the matching DeleteEmployee method is called.

The following code example shows the Web page that displays the DataGrid control and handles the Deleting event.

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

The following code example shows the EmployeeLogic class that is used in the preceding code example.

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