ObjectDataSourceView.ExecuteSelect Method

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.

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

protected internal override IEnumerable ExecuteSelect(
	DataSourceSelectArguments arguments
)

Parameters

arguments
Type: System.Web.UI.DataSourceSelectArguments

A DataSourceSelectArguments used to request operations on the data beyond basic data retrieval.

Return Value

Type: System.Collections.IEnumerable
A IEnumerable list of data rows.

ExceptionCondition
NotSupportedException

The arguments passed to the ExecuteSelect method specify that the data source should perform some additional work while retrieving data to enable paging or sorting through the retrieved data, but the data source control does not support the requested capability.

- or -

The object returned by the ExecuteSelect method is not a DataSet or DataTable, and caching is enabled. Only DataSet and DataTable objects can be cached for the ObjectDataSourceView control.

- or -

Both caching and client impersonation are enabled. The ObjectDataSource does not support caching when client impersonation is enabled.

InvalidOperationException

The object returned by the ExecuteSelect method is a DataSet, but has no tables in its Tables collection.

- or -

The EnablePaging property is set to true, but the StartRowIndexParameterName and MaximumRowsParameterName properties are not set.

The ObjectDataSourceView class implements the inherited ExecuteSelect method to retrieve data using a business object. Page developers and data-bound control authors do not call the ExecuteSelect method directly; instead, use the publicly exposed Select method.

The specified method can have any method signature, but must return one of the types for the ObjectDataSource control that are listed in the following table to call it successfully.

Return type

Action

IEnumerable

The IEnumerable is returned by the Select method.

DataTable

A DataView is created using the DataTable and returned by the Select method.

DataSet

The first DataTable of the DataSet is extracted and a DataView is created and returned by the Select method.

Object

The object is wrapped in a one-element IEnumerable and returned by the Select method.

Before the data retrieval is performed, the OnSelecting method is called to raise the Selecting event. You can handle this event to examine the values of the parameters and to perform any preprocessing before an operation.

To perform a select operation, the ObjectDataSourceView control uses reflection to call the method that is identified by the SelectMethod property and any associated parameters that are in the SelectParameters collection, and then executes it. After the operation completes, the OnSelected method is called to raise the Selected event. You can handle this event to examine any return values and error codes, and to perform any post-processing.

If the Select method returns a DataSet object and caching is enabled, the ObjectDataSourceView retrieves data from and saves data to the cache during the operation. The cache is created, discarded, or refreshed based on the caching behavior that is specified by the combination of the CacheDuration and CacheExpirationPolicy properties.

If the Select method returns a DataSet object and a FilterExpression property has been specified, it is evaluated along with any supplied FilterParameters properties and the resulting filter is applied to the list of data during the Select operation.

For information on returning the number of rows selected, see Select.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft