ObjectDataSourceView.DeleteMethod Property
Assembly: System.Web (in system.web.dll)
/** @property */ public String get_DeleteMethod () /** @property */ public void set_DeleteMethod (String value)
public function get DeleteMethod () : String public function set DeleteMethod (value : String)
Property Value
A string that represents the name of the method or function that the ObjectDataSourceView uses to delete data. The default is an empty string ("").The method that is identified by the DeleteMethod 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 DeleteMethod property is called. You can handle the ObjectCreated event to work with the business object before the method specified by the DeleteMethod property is called. You can also handle the ObjectDisposing event that is raised after the method specified by the DeleteMethod property is called. 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 control works with 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 DeleteParameters collection. If the parameters in the DeleteParameters collection do not match those of the DeleteMethod method signature, the data source throws an exception.
The value of the DeleteMethod property is stored in view state.
For more information, see DeleteMethod.
The following code example demonstrates how to use an ObjectDataSource control with a business object and a GridView control to delete data. The GridView initially 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 DeleteMethod property and any parameters that are specified in 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 Delete operation is performed, and the NorthwindEmployeeDeleted delegate is called to handle the Deleted event after the Delete operation has completed, to perform an exception handling. In this example, if a NorthwindDataException is thrown, it is handled by this delegate.
To examine the implementation of the EmployeeLogic middle-tier business object that this code example uses, see ObjectDataSourceStatusEventArgs.
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.