ObjectDataSourceView ObjectDataSourceView ObjectDataSourceView ObjectDataSourceView Class

Definition

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

public ref class ObjectDataSourceView : System::Web::UI::DataSourceView, System::Web::UI::IStateManager
public class ObjectDataSourceView : System.Web.UI.DataSourceView, System.Web.UI.IStateManager
type ObjectDataSourceView = class
    inherit DataSourceView
    interface IStateManager
Public Class ObjectDataSourceView
Inherits DataSourceView
Implements IStateManager
Inheritance
ObjectDataSourceViewObjectDataSourceViewObjectDataSourceViewObjectDataSourceView
Implements

Remarks

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.

Constructors

ObjectDataSourceView(ObjectDataSource, String, HttpContext) ObjectDataSourceView(ObjectDataSource, String, HttpContext) ObjectDataSourceView(ObjectDataSource, String, HttpContext) ObjectDataSourceView(ObjectDataSource, String, HttpContext)

Initializes a new instance of the ObjectDataSourceView class.

Properties

CanDelete CanDelete CanDelete CanDelete

Gets a value indicating whether the ObjectDataSourceView object that is associated with the current ObjectDataSource control supports the delete operation.

CanInsert CanInsert CanInsert CanInsert

Gets a value indicating whether the ObjectDataSourceView object that is associated with the current ObjectDataSource control supports the insert operation.

CanPage CanPage CanPage CanPage

Gets a value indicating whether the ObjectDataSourceView object that is associated with the current ObjectDataSource control supports paging through the retrieved data.

CanRetrieveTotalRowCount CanRetrieveTotalRowCount CanRetrieveTotalRowCount CanRetrieveTotalRowCount

Gets a value indicating whether the ObjectDataSourceView object that is associated with the current ObjectDataSource control supports retrieving the total number of data rows, in addition to the set of data.

CanSort CanSort CanSort CanSort

Gets a value indicating whether the ObjectDataSourceView object that is associated with the current ObjectDataSource control supports a sorted view on the underlying data source.

CanUpdate CanUpdate CanUpdate CanUpdate

Gets a value indicating whether the ObjectDataSourceView object that is associated with the current ObjectDataSource control supports the update operation.

ConflictDetection ConflictDetection ConflictDetection ConflictDetection

Gets or sets a value that determines how the ObjectDataSource control performs updates and deletes when data in a row in the underlying data storage changes during the time of the operation.

ConvertNullToDBNull ConvertNullToDBNull ConvertNullToDBNull ConvertNullToDBNull

Gets or sets a value indicating whether Parameter values that are passed to an update, insert, or delete operation are automatically converted from null to the Value value.

DataObjectTypeName DataObjectTypeName DataObjectTypeName DataObjectTypeName

Gets or sets the name of a class that the ObjectDataSource control uses for a parameter in a data operation. The ObjectDataSource control uses the specified class instead of the Parameter objects that are in the various parameters collections.

DeleteMethod DeleteMethod DeleteMethod DeleteMethod

Gets or sets the name of the method or function that the ObjectDataSourceView object invokes to delete data.

DeleteParameters DeleteParameters DeleteParameters DeleteParameters

Gets the parameters collection that contains the parameters that are used by the DeleteMethod method.

EnablePaging EnablePaging EnablePaging EnablePaging

Gets or sets a value indicating whether the data source control supports paging through the set of data that it retrieves.

Events Events Events Events

Gets a list of event-handler delegates for the data source view.

(Inherited from DataSourceView)
FilterExpression FilterExpression FilterExpression FilterExpression

Gets or sets a filtering expression that is applied when the business object method that is identified by the SelectMethod property is called.

FilterParameters FilterParameters FilterParameters FilterParameters

Gets a collection of parameters that are associated with any parameter placeholders that are in the FilterExpression string.

InsertMethod InsertMethod InsertMethod InsertMethod

Gets or sets the name of the method or function that the ObjectDataSourceView object invokes to insert data.

InsertParameters InsertParameters InsertParameters InsertParameters

Gets the parameters collection that contains the parameters that are used by the InsertMethod method.

IsTrackingViewState IsTrackingViewState IsTrackingViewState IsTrackingViewState

Gets a value indicating whether the ObjectDataSourceView object is saving changes to its view state.

MaximumRowsParameterName MaximumRowsParameterName MaximumRowsParameterName MaximumRowsParameterName

Gets or sets the name of the data retrieval method parameter that is used to indicate the number of records to retrieve for data source paging support.

Name Name Name Name

Gets the name of the data source view.

(Inherited from DataSourceView)
OldValuesParameterFormatString OldValuesParameterFormatString OldValuesParameterFormatString OldValuesParameterFormatString

Gets or sets a format string to apply to the names of the parameters for original values that are passed to the Delete or Update methods.

ParsingCulture ParsingCulture ParsingCulture ParsingCulture

Gets a or sets a value that indicates what culture information is used when converting string values to actual property types in order to construct an object of the type indicated by DataObjectTypeName.

SelectCountMethod SelectCountMethod SelectCountMethod SelectCountMethod

Gets or sets the name of the method or function that the ObjectDataSourceView control invokes to retrieve a row count.

SelectMethod SelectMethod SelectMethod SelectMethod

Gets or sets the name of the method or function that the ObjectDataSourceView control invokes to retrieve data.

SelectParameters SelectParameters SelectParameters SelectParameters

Gets the parameters collection containing the parameters that are used by the SelectMethod method.

SortParameterName SortParameterName SortParameterName SortParameterName

Gets or sets the name of the data retrieval method parameter that is used to specify a sort expression for data source sorting support.

StartRowIndexParameterName StartRowIndexParameterName StartRowIndexParameterName StartRowIndexParameterName

Gets or sets the name of the data retrieval method parameter that is used to indicate the integer index of the first record to retrieve from the results set for data source paging support.

TypeName TypeName TypeName TypeName

Gets or sets the name of the class that the ObjectDataSource control represents.

UpdateMethod UpdateMethod UpdateMethod UpdateMethod

Gets or sets the name of the method or function that the ObjectDataSourceView object invokes to update data.

UpdateParameters UpdateParameters UpdateParameters UpdateParameters

Gets the parameters collection containing the parameters that are used by the UpdateMethod method.

Methods

CanExecute(String) CanExecute(String) CanExecute(String) CanExecute(String)

Determines whether the specified command can be executed.

(Inherited from DataSourceView)
Delete(IDictionary, IDictionary) Delete(IDictionary, IDictionary) Delete(IDictionary, IDictionary) Delete(IDictionary, IDictionary)

Performs a delete operation by calling the business object method that is identified by the DeleteMethod property using the specified keys and oldValues collections.

Delete(IDictionary, IDictionary, DataSourceViewOperationCallback) Delete(IDictionary, IDictionary, DataSourceViewOperationCallback) Delete(IDictionary, IDictionary, DataSourceViewOperationCallback) Delete(IDictionary, IDictionary, DataSourceViewOperationCallback)

Performs an asynchronous delete operation on the list of data that the DataSourceView object represents.

(Inherited from DataSourceView)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
ExecuteCommand(String, IDictionary, IDictionary) ExecuteCommand(String, IDictionary, IDictionary) ExecuteCommand(String, IDictionary, IDictionary) ExecuteCommand(String, IDictionary, IDictionary)

Executes the specified command.

(Inherited from DataSourceView)
ExecuteCommand(String, IDictionary, IDictionary, DataSourceViewOperationCallback) ExecuteCommand(String, IDictionary, IDictionary, DataSourceViewOperationCallback) ExecuteCommand(String, IDictionary, IDictionary, DataSourceViewOperationCallback) ExecuteCommand(String, IDictionary, IDictionary, DataSourceViewOperationCallback)

Executes the specified command.

(Inherited from DataSourceView)
ExecuteDelete(IDictionary, IDictionary) ExecuteDelete(IDictionary, IDictionary) ExecuteDelete(IDictionary, IDictionary) ExecuteDelete(IDictionary, IDictionary)

Performs a delete operation using the DeleteMethod method and the specified keys and oldValues collection.

ExecuteInsert(IDictionary) ExecuteInsert(IDictionary) ExecuteInsert(IDictionary) ExecuteInsert(IDictionary)

Performs an insert operation by calling the business object method that is identified by the InsertMethod property using the specified values collection.

ExecuteSelect(DataSourceSelectArguments) ExecuteSelect(DataSourceSelectArguments) ExecuteSelect(DataSourceSelectArguments) ExecuteSelect(DataSourceSelectArguments)

Retrieves data from the object that is identified by the TypeName property by calling the method that is identified by the SelectMethod property and passing any values in the SelectParameters collection.

ExecuteUpdate(IDictionary, IDictionary, IDictionary) ExecuteUpdate(IDictionary, IDictionary, IDictionary) ExecuteUpdate(IDictionary, IDictionary, IDictionary) ExecuteUpdate(IDictionary, IDictionary, IDictionary)

Performs an update operation by calling the method that is identified by the UpdateMethod property and using any parameters that are supplied in the keys, values, or oldValues collections.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
Insert(IDictionary) Insert(IDictionary) Insert(IDictionary) Insert(IDictionary)

Performs an insert operation by calling the business object method that is identified by the InsertMethod property using the specified values collection.

Insert(IDictionary, DataSourceViewOperationCallback) Insert(IDictionary, DataSourceViewOperationCallback) Insert(IDictionary, DataSourceViewOperationCallback) Insert(IDictionary, DataSourceViewOperationCallback)

Performs an asynchronous insert operation on the list of data that the DataSourceView object represents.

(Inherited from DataSourceView)
LoadViewState(Object) LoadViewState(Object) LoadViewState(Object) LoadViewState(Object)

Restores previously saved view state for the data source view.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
OnDataSourceViewChanged(EventArgs) OnDataSourceViewChanged(EventArgs) OnDataSourceViewChanged(EventArgs) OnDataSourceViewChanged(EventArgs)

Raises the DataSourceViewChanged event.

(Inherited from DataSourceView)
OnDeleted(ObjectDataSourceStatusEventArgs) OnDeleted(ObjectDataSourceStatusEventArgs) OnDeleted(ObjectDataSourceStatusEventArgs) OnDeleted(ObjectDataSourceStatusEventArgs)

Raises the Deleted event after the ObjectDataSourceView object has completed a delete operation.

OnDeleting(ObjectDataSourceMethodEventArgs) OnDeleting(ObjectDataSourceMethodEventArgs) OnDeleting(ObjectDataSourceMethodEventArgs) OnDeleting(ObjectDataSourceMethodEventArgs)

Raises the Deleting event before the ObjectDataSourceView object attempts a delete operation.

OnFiltering(ObjectDataSourceFilteringEventArgs) OnFiltering(ObjectDataSourceFilteringEventArgs) OnFiltering(ObjectDataSourceFilteringEventArgs) OnFiltering(ObjectDataSourceFilteringEventArgs)

Raises the Filtering event before the ObjectDataSourceView object attempts a filtering operation.

OnInserted(ObjectDataSourceStatusEventArgs) OnInserted(ObjectDataSourceStatusEventArgs) OnInserted(ObjectDataSourceStatusEventArgs) OnInserted(ObjectDataSourceStatusEventArgs)

Raises the Inserted event after the ObjectDataSourceView object has completed an insert operation.

OnInserting(ObjectDataSourceMethodEventArgs) OnInserting(ObjectDataSourceMethodEventArgs) OnInserting(ObjectDataSourceMethodEventArgs) OnInserting(ObjectDataSourceMethodEventArgs)

Raises the Inserting event before the ObjectDataSourceView object attempts an insert operation.

OnObjectCreated(ObjectDataSourceEventArgs) OnObjectCreated(ObjectDataSourceEventArgs) OnObjectCreated(ObjectDataSourceEventArgs) OnObjectCreated(ObjectDataSourceEventArgs)

Raises the ObjectCreated event after the ObjectDataSourceView creates an instance of the object that is identified by the TypeName property.

OnObjectCreating(ObjectDataSourceEventArgs) OnObjectCreating(ObjectDataSourceEventArgs) OnObjectCreating(ObjectDataSourceEventArgs) OnObjectCreating(ObjectDataSourceEventArgs)

Raises the ObjectCreating event before the ObjectDataSourceView object creates an instance of a business object to perform a data operation.

OnObjectDisposing(ObjectDataSourceDisposingEventArgs) OnObjectDisposing(ObjectDataSourceDisposingEventArgs) OnObjectDisposing(ObjectDataSourceDisposingEventArgs) OnObjectDisposing(ObjectDataSourceDisposingEventArgs)

Raises the ObjectDisposing event before the ObjectDataSourceView object discards an instantiated type.

OnSelected(ObjectDataSourceStatusEventArgs) OnSelected(ObjectDataSourceStatusEventArgs) OnSelected(ObjectDataSourceStatusEventArgs) OnSelected(ObjectDataSourceStatusEventArgs)

Raises the Selected event after the ObjectDataSourceView object has completed a data retrieval operation.

OnSelecting(ObjectDataSourceSelectingEventArgs) OnSelecting(ObjectDataSourceSelectingEventArgs) OnSelecting(ObjectDataSourceSelectingEventArgs) OnSelecting(ObjectDataSourceSelectingEventArgs)

Raises the Selecting event before the ObjectDataSourceView object attempts a data retrieval operation.

OnUpdated(ObjectDataSourceStatusEventArgs) OnUpdated(ObjectDataSourceStatusEventArgs) OnUpdated(ObjectDataSourceStatusEventArgs) OnUpdated(ObjectDataSourceStatusEventArgs)

Raises the Updated event after the ObjectDataSourceView object has completed an update operation.

OnUpdating(ObjectDataSourceMethodEventArgs) OnUpdating(ObjectDataSourceMethodEventArgs) OnUpdating(ObjectDataSourceMethodEventArgs) OnUpdating(ObjectDataSourceMethodEventArgs)

Raises the Updating event before the ObjectDataSourceView object attempts an update operation.

RaiseUnsupportedCapabilityError(DataSourceCapabilities) RaiseUnsupportedCapabilityError(DataSourceCapabilities) RaiseUnsupportedCapabilityError(DataSourceCapabilities) RaiseUnsupportedCapabilityError(DataSourceCapabilities)

Called by the RaiseUnsupportedCapabilitiesError(DataSourceView) method to compare the capabilities requested for an ExecuteSelect(DataSourceSelectArguments) operation against those that the view supports.

(Inherited from DataSourceView)
SaveViewState() SaveViewState() SaveViewState() SaveViewState()

Saves the changes to the view state for the ObjectDataSourceView object since the time when the page was posted back to the server.

Select(DataSourceSelectArguments) Select(DataSourceSelectArguments) Select(DataSourceSelectArguments) Select(DataSourceSelectArguments)

Retrieves data from the object that is identified by the TypeName property by calling the method that is identified by the SelectMethod property and passing any values in the SelectParameters collection.

Select(DataSourceSelectArguments, DataSourceViewSelectCallback) Select(DataSourceSelectArguments, DataSourceViewSelectCallback) Select(DataSourceSelectArguments, DataSourceViewSelectCallback) Select(DataSourceSelectArguments, DataSourceViewSelectCallback)

Gets a list of data asynchronously from the underlying data storage.

(Inherited from DataSourceView)
ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)
TrackViewState() TrackViewState() TrackViewState() TrackViewState()

Causes the ObjectDataSourceView object to track changes to its view state so that the changes can be stored in the ViewState object for the control and persisted across requests for the same page.

Update(IDictionary, IDictionary, IDictionary) Update(IDictionary, IDictionary, IDictionary) Update(IDictionary, IDictionary, IDictionary) Update(IDictionary, IDictionary, IDictionary)

Performs an update operation by calling the method that is identified by the UpdateMethod property and using any parameters that are supplied in the keys, values, or oldValues collections.

Update(IDictionary, IDictionary, IDictionary, DataSourceViewOperationCallback) Update(IDictionary, IDictionary, IDictionary, DataSourceViewOperationCallback) Update(IDictionary, IDictionary, IDictionary, DataSourceViewOperationCallback) Update(IDictionary, IDictionary, IDictionary, DataSourceViewOperationCallback)

Performs an asynchronous update operation on the list of data that the DataSourceView object represents.

(Inherited from DataSourceView)

Events

DataSourceViewChanged DataSourceViewChanged DataSourceViewChanged DataSourceViewChanged

Occurs when the data source view has changed.

(Inherited from DataSourceView)
Deleted Deleted Deleted Deleted

Occurs when a Delete operation has completed.

Deleting Deleting Deleting Deleting

Occurs before a Delete operation.

Filtering Filtering Filtering Filtering

Occurs before a filter operation.

Inserted Inserted Inserted Inserted

Occurs when an Insert operation has completed.

Inserting Inserting Inserting Inserting

Occurs before an Insert operation.

ObjectCreated ObjectCreated ObjectCreated ObjectCreated

Occurs after the ObjectDataSourceView object creates an instance of the type that is identified by the TypeName property.

ObjectCreating ObjectCreating ObjectCreating ObjectCreating

Occurs before the ObjectDataSourceView object creates an instance of the type that is identified by the TypeName property.

ObjectDisposing ObjectDisposing ObjectDisposing ObjectDisposing

Occurs when the ObjectDataSourceView object discards an instance of an object that it has created.

Selected Selected Selected Selected

Occurs when a data retrieval operation has completed.

Selecting Selecting Selecting Selecting

Occurs before a data retrieval operation.

Updated Updated Updated Updated

Occurs when an Update operation has completed.

Updating Updating Updating Updating

Occurs before an Update operation.

Explicit Interface Implementations

IStateManager.IsTrackingViewState IStateManager.IsTrackingViewState IStateManager.IsTrackingViewState IStateManager.IsTrackingViewState

For a description of this member, see IsTrackingViewState.

IStateManager.LoadViewState(Object) IStateManager.LoadViewState(Object) IStateManager.LoadViewState(Object) IStateManager.LoadViewState(Object)

For a description of this member, see LoadViewState(Object).

IStateManager.SaveViewState() IStateManager.SaveViewState() IStateManager.SaveViewState() IStateManager.SaveViewState()

For a description of this member, see SaveViewState().

IStateManager.TrackViewState() IStateManager.TrackViewState() IStateManager.TrackViewState() IStateManager.TrackViewState()

For a description of this member, see TrackViewState().

Applies to

See also