Assembly: System.Web (in System.Web.dll)
Initializes a new instance of theclass using the specified output parameters and return value.
|ObjectDataSourceStatusEventArgs(Object, IDictionary, Exception)|
Initializes a new instance of theclass using the specified output parameters, return value, and exception.
Gets or sets the number of rows that are affected by the data operation.
Gets a wrapper for any exceptions that are thrown by the method that is called by the ObjectDataSource control during a data operation.
Gets or sets a value indicating whether an exception that was thrown by the business object has been handled.
Gets a collection that contains business object method parameters and their values.
Gets the return value that is returned by the business object method, if any, as an object.
Determines whether the specified object is equal to the current object.(Inherited from Object.)
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)
Serves as the default hash function. (Inherited from Object.)
Returns a string that represents the current object.(Inherited from Object.)
The OnSelected, OnUpdated, OnInserted, and OnDeleted methods to provide access to output parameters, return values, and exceptions that are thrown by the method that is called by the ObjectDataSource control. These are accessed by the OutputParameters, ReturnValue, and Exception properties, respectively. By adding a delegate to handle the Selected, Updated, Inserted, or Deleted events, you can examine this data and perform any additional post processing that is required.class is used in the
The ObjectDataSource control exposes many events that you can handle to work with the underlying business object at various times in its lifecycle. The following table lists the events and the associated EventArgs classes and event handler delegates.
Occurs immediately before the instance of the business object is created.
Occurs immediately after the instance of the business object is created.
Occurs before the data is retrieved.
Occur before an insert, update, or delete operation is performed.
Occurs after the data is retrieved.
Occur after the insert, update, or delete operation is completed.
Occurs before a business object is destroyed.
This section contains two code examples. The first code example demonstrates how to use an ObjectDataSource control with a business object and a GridView control to delete data. The second code example provides an example middle-tier business object that the first code example uses.
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 action 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, one parameter is specified in the DeleteParameters collection that corresponds to the employee ID. This is because although the ID is included in the Columns collection as a BoundField object, it will be passed as a string to the ObjectDataSource control. By adding it explicitly to the DeleteParameters collection with a Type property set to the Int32 value, it will pass correctly by the ObjectDataSource to the method as an integer, rather than as string.
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 action is performed, and the NorthwindEmployeeDeleted delegate is called to handle the Deleted event after the Delete action has completed, to handle any exceptions that might have occurred. The NorthwindEmployeeDeleted delegate accesses possible exceptions that are thrown by the business object that is using the object. In this example, if a NorthwindDataException is thrown, it is handled by this delegate.
The following code example provides an example middle-tier business object that the preceding code example uses. The following list describes the two major classes that are defined in the code example:
The EmployeeLogic class is a class that does not maintain state and encapsulates business logic.
The NorthwindEmployee class is a model class that contains only the basic functionality that is required to load and persist data from the data tier.
In addition, a NorthwindDataException class is provided as a convenience.
This set of example classes uses the Northwind Traders database, which is an example database that is available with Microsoft SQL Server and Microsoft Access. For a complete working example, you must compile this code as a library, and then use these classes from an ASP page. The ASP page that is provided in the preceding example is configured to work with this class library. The UpdateEmployeeInfo method is not completely implemented, so you will not insert data into the Northwind Traders database when you experiment with this example.
Available since 2.0
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.