Gets or sets the name of the method or function that the ObjectDataSource control invokes to delete data.
Assembly: System.Web (in System.Web.dll)
The business object is assumed to delete data one record at a time, rather than in a batch.
The method that is identified by the ObjectCreated and ObjectCreating events to work with the business object before the property is called. You can also handle the ObjectDisposing event that is raised after the property is called. If the business object implements the IDisposable interface, the Dispose method is called before the object is destroyed. If the method is a static (Shared in Visual Basic) method, the business object is never created and you cannot handle the ObjectCreated, ObjectCreating, and ObjectDisposing events.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 property is called. You can handle the
Parameters are added to the DeleteParameters collection from three sources:
From the data-bound control, at run time.
From the DeleteParameters element, declaratively.
From the Deleting method, declaratively.
First, any parameters that are generated from data-bound controls are added to the DeleteParameters collection. For example, if the ObjectDataSource control is bound to a GridView control that has the columns Name and Number, parameters for Name and Number are added to the collection. The exact name of the parameter depends on the OldValuesParameterFormatString property. The data type of these parameters is string. Next, the parameters that are listed in the DeleteParameters element are added. If a parameter in the DeleteParameters element is found with the same name as a parameter that is already in the DeleteParameters collection, the existing parameter is modified to match the parameter that is specified in the DeleteParameters element. Typically, this is used to modify the type of the data in the parameter. Finally, you can programmatically add and remove parameters in the Deleting event, which occurs before the Delete method is run. The method is resolved after the parameters are merged. Method resolution is discussed in the next section.
When the Delete method is called, the data fields from the data-bound control, the parameters that were created declaratively in the DeleteParameters element, and the parameters that were added in the Deleting event handler are all merged. (For more information, see the preceding section.) The ObjectDataSource object then attempts to find a method to call. First, it looks for one or more methods with the name that is specified in the property. If no match is found, an InvalidOperationException exception is thrown. If a match is found, it then looks for matching parameter names. For example, suppose the type that is specified by the TypeName property has two methods named DeleteARecord. One DeleteARecord has one parameter, ID, and the other DeleteARecord has two parameters, Name and Number. If the DeleteParameters collection has only one parameter named ID, the DeleteARecord method with just the ID parameter is called. The type of the parameter is not checked in resolving the methods. The order of the parameters does not matter.
If the DataObjectTypeName property is set, the method is resolved in a different way. The ObjectDataSource looks for a method with the name that is specified in the property that takes one parameter of the type that is specified in the DataObjectTypeName property. In this case, the name of the parameter does not matter.
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 an 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 delete operation is performed using the method that is specified by the DeleteParameters collection. In this code example, some preprocessing and post-processing steps are also performed. The NorthwindEmployeeDeleting delegate is called to handle the Deleting event before the operation is performed, and the NorthwindEmployeeDeleted delegate is called to handle the Deleted event after the operation has completed to perform exception handling. In this example, if a NorthwindDataException is thrown, it is handled by the NorthwindDataException delegate.property and any parameters that are specified in the
The following code example shows the EmployeeLogic class that is used in the preceding code example.
Available since 2.0