System.Web.UI.WebControls.ObjectDataSourceView Class

Supports the System.Web.UI.WebControls.ObjectDataSource control and provides an interface for data-bound controls to perform data operations with business and data objects.

See Also: ObjectDataSourceView Members

Syntax

public class ObjectDataSourceView : System.Web.UI.DataSourceView, System.Web.UI.IStateManager

Remarks

The System.Web.UI.WebControls.ObjectDataSourceView class is intended primarily to be used by data-bound controls, and not as a programmable object in page code.

The System.Web.UI.WebControls.ObjectDataSourceView class implements the data functionality for the System.Web.UI.WebControls.ObjectDataSource control, including the ObjectDataSourceView.Select(System.Web.UI.DataSourceSelectArguments), ObjectDataSourceView.Update(IDictionary, IDictionary, IDictionary), ObjectDataSourceView.Delete(IDictionary, IDictionary), and ObjectDataSourceView.Insert(IDictionary) operations, sorting, filtering, and management of settings kept in view state.

A System.Web.UI.WebControls.ObjectDataSourceView object is created for each instance of the System.Web.UI.WebControls.ObjectDataSource class at run time. Calls to data operations of the instance of the System.Web.UI.WebControls.ObjectDataSource class are handled by the instance of the System.Web.UI.WebControls.ObjectDataSourceView object. Page developers do not access the instance of the System.Web.UI.WebControls.ObjectDataSourceView class directly. Control developers can create custom data controls by extending the System.Web.UI.WebControls.ObjectDataSource and System.Web.UI.WebControls.ObjectDataSourceView classes.

The System.Web.UI.WebControls.ObjectDataSourceView class performs data operations by calling methods on business or data objects using reflection. At run time, the System.Web.UI.WebControls.ObjectDataSource control creates an instance of the type that is identified by the ObjectDataSourceView.TypeName property, and then calls the appropriate method for the data operation. The instantiated object is not cached in memory by the System.Web.UI.WebControls.ObjectDataSourceView. The object is created and destroyed for every data method call. If the method is static (Shared in Visual Basic), an instance is not created but the data operation method is still called.

The System.Web.UI.WebControls.ObjectDataSourceView is not directly exposed to page developers by the System.Web.UI.WebControls.ObjectDataSource control. Instead, the properties and methods of the System.Web.UI.WebControls.ObjectDataSourceView are accessed through the System.Web.UI.WebControls.ObjectDataSource. For example, the ObjectDataSource.DeleteMethod of System.Web.UI.WebControls.ObjectDataSourceView property is set by setting the ObjectDataSource.DeleteMethod property of the System.Web.UI.WebControls.ObjectDataSource.

Retrieving Data

The most basic operation that a data source view performs is data retrieval from the underlying data storage using the ObjectDataSourceView.Select(System.Web.UI.DataSourceSelectArguments) method, which retrieves an IEnumerable collection of data items. The following data retrieval methods, properties, and events are implemented by the System.Web.UI.WebControls.ObjectDataSourceView object and exposed directly by its System.Web.UI.WebControls.ObjectDataSource control to page developers and other callers:

Updating Data

The System.Web.UI.WebControls.ObjectDataSourceView object supports data updates by calling a business or data object method that is identified by the ObjectDataSourceView.UpdateMethod property. Data-bound controls that automatically perform updates, such as the System.Web.UI.WebControls.GridView and System.Web.UI.WebControls.DetailsView controls, pass their parameters in an System.Collections.Specialized.IOrderedDictionary interface to the System.Web.UI.WebControls.ObjectDataSourceView and the view object merges these parameters with any parameters that are found in the ObjectDataSourceView.UpdateParameters collection.

The following update methods, properties, and events are implemented by the System.Web.UI.WebControls.ObjectDataSourceView and exposed directly by its System.Web.UI.WebControls.ObjectDataSource control to page developers and other callers:

Inserting Data

The System.Web.UI.WebControls.ObjectDataSourceView object supports inserting new rows of data by calling a business or data object method that is identified by the ObjectDataSourceView.InsertMethod property. Data-bound controls that automatically perform inserts, such as the System.Web.UI.WebControls.GridView and System.Web.UI.WebControls.DetailsView, pass their parameters in an System.Collections.Specialized.IOrderedDictionary interface to the System.Web.UI.WebControls.ObjectDataSourceView and the view object merges these parameters with any parameters that are found in the ObjectDataSourceView.InsertParameters collection.

The following insert methods, properties, and events are implemented by the System.Web.UI.WebControls.ObjectDataSourceView and exposed directly by its System.Web.UI.WebControls.ObjectDataSource control to page developers and other callers:

Deleting Data

The System.Web.UI.WebControls.ObjectDataSourceView object supports deleting data by calling a business or data object method that is identified by the ObjectDataSourceView.DeleteMethod property. Data-bound controls that automatically perform deletes, such as the System.Web.UI.WebControls.GridView and System.Web.UI.WebControls.DetailsView, pass their parameters in an System.Collections.Specialized.IOrderedDictionary interface to the System.Web.UI.WebControls.ObjectDataSourceView and the view object merges these parameters with any parameters that are found in the ObjectDataSourceView.DeleteParameters collection. The following delete methods, properties, and events are implemented by the System.Web.UI.WebControls.ObjectDataSourceView and exposed directly by its System.Web.UI.WebControls.ObjectDataSource control to page developers and other callers:

Filtering and Sorting Data

Data retrieval is more powerful when you can filter the data dynamically. Filtering is supported only by the System.Web.UI.WebControls.ObjectDataSource control if the ObjectDataSourceView.Select(System.Web.UI.DataSourceSelectArguments) method returns a System.Data.DataTable or System.Data.DataSet object. You can use the ObjectDataSourceView.FilterExpression and ObjectDataSourceView.FilterParameters properties to apply dynamic filtering to data retrieval. These properties are implemented by the System.Web.UI.WebControls.ObjectDataSourceView object and exposed directly by its System.Web.UI.WebControls.ObjectDataSource control to data-bound controls and other callers.

You can sort the data that you retrieve with the System.Web.UI.WebControls.ObjectDataSource by ordering the data in memory after it is retrieved. Sorting is supported only by the System.Web.UI.WebControls.ObjectDataSource control if the ObjectDataSourceView.Select(System.Web.UI.DataSourceSelectArguments) method returns a System.Data.DataTable or System.Data.DataSet. The ObjectDataSourceView.CanSort property always returns true, because the System.Web.UI.WebControls.ObjectDataSourceView cannot determine what type is returned by the ObjectDataSourceView.Select(System.Web.UI.DataSourceSelectArguments) method without calling the method. The System.Web.UI.DataSourceSelectArguments.SortExpression property syntax is the same as for a System.Data.DataView.Sort property.

Tracking View State

The System.Web.UI.WebControls.ObjectDataSourceView implements the System.Web.UI.IStateManager interface and uses view state to track its state across page requests. Implementation of the ObjectDataSourceView.LoadViewState(object), ObjectDataSourceView.SaveViewState, and ObjectDataSourceView.TrackViewState methods are provided to enable view state tracking for the control. For more information, see ASP.NET State Management Overview.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0