Export (0) Print
Expand All

SqlDataSource.Select Method

Retrieves data from the underlying database using the SelectCommand SQL string and any parameters that are in the SelectParameters collection.

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

public IEnumerable Select (
	DataSourceSelectArguments arguments
)
public IEnumerable Select (
	DataSourceSelectArguments arguments
)
public function Select (
	arguments : DataSourceSelectArguments
) : IEnumerable
Not applicable.

Parameters

arguments

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

Return Value

An IEnumerable list of data rows.

Exception typeCondition

InvalidOperationException

The SqlDataSource cannot establish a connection with the underlying data source.

The Select method returns a DataView object, if the DataSourceMode property is set to the DataSet value, or a IDataReader object, if the DataSourceMode property is set to the DataReader value. Close the IDataReader object when you have finished reading the data.

Before the Select operation 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 the Select operation.

After the Select 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 DataSourceMode property is set to the DataSet value and caching is enabled, the SqlDataSource object retrieves data from and saves data to the cache during the Select 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.

Security noteSecurity Note:

When you are using client impersonation under Microsoft Windows authentication, the data is cached when the first user accesses the data. If another user requests the same data, the data is retrieved from the cache. The data is not retrieved by making another call to the database to verify the user's access to the data. If you expect more than one user to access the data, and you want each retrieval to the data to be verified by the security configurations for the database, do not use caching.

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

The Select method delegates to the Select method of the SqlDataSourceView object that is associated with the SqlDataSource control. To perform a data retrieval operation, the SqlDataSourceView builds a DbCommand object using the SelectCommand text and any associated SelectParameters, and then executes the DbCommand against the underlying database.

Security noteSecurity Note:

Values are inserted into parameters without validation, which is a potential security threat. Use the Filtering event to validate parameter values before executing the query. For more information, see Script Exploits Overview (Visual Studio).

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2015 Microsoft