Export (0) Print
Expand All

ObjectDataSourceView Class

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

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

[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class ObjectDataSourceView : DataSourceView, 
	IStateManager

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

The ObjectDataSourceView class implements the data functionality for the ObjectDataSource control, including the Select, Update, Delete, and Insert operations, sorting, filtering, and management of settings kept in view state.

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

The ObjectDataSourceView class performs data operations by calling methods on business or data objects using reflection. At run time, the ObjectDataSource control creates an instance of the type that is identified by the TypeName property, and then calls the appropriate method for the data operation. The instantiated object is not cached in memory by the 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 ObjectDataSourceView is not directly exposed to page developers by the ObjectDataSource control. Instead, the properties and methods of the ObjectDataSourceView are accessed through the ObjectDataSource. For example, the DeleteMethod of ObjectDataSourceView property is set by setting the DeleteMethod property of the ObjectDataSource.

Retrieving Data

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

Updating Data

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

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

Inserting Data

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

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

Deleting Data

The ObjectDataSourceView object supports deleting data by calling a business or data object method that is identified by the DeleteMethod property. Data-bound controls that automatically perform deletes, such as the GridView and DetailsView, pass their parameters in an IOrderedDictionary interface to the ObjectDataSourceView and the view object merges these parameters with any parameters that are found in the DeleteParameters collection. The following delete methods, properties, and events are implemented by the ObjectDataSourceView and exposed directly by its 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 ObjectDataSource control if the Select method returns a DataTable or DataSet object. You can use the FilterExpression and FilterParameters properties to apply dynamic filtering to data retrieval. These properties are implemented by the ObjectDataSourceView object and exposed directly by its ObjectDataSource control to data-bound controls and other callers.

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

Tracking View State

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

System.Object
  System.Web.UI.DataSourceView
    System.Web.UI.WebControls.ObjectDataSourceView

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft