System.Web.UI.WebControls.SqlDataSource.Select Method

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

Syntax

public IEnumerable Select (System.Web.UI.DataSourceSelectArguments args)

Parameters

args
Documentation for this section has not yet been entered.

Returns

An IEnumerable list of data rows.

Remarks

The SqlDataSource.Select(System.Web.UI.DataSourceSelectArguments) method is automatically called during the System.Web.UI.Control.PreRender phase of the page life cycle. It is called by data-bound controls that have been attached to a System.Web.UI.WebControls.SqlDataSource control through their DataBoundControl.DataSourceID property.

The erload:System.Web.UI.WebControls.SqlDataSourceView.Select method returns a System.Data.DataView object if the SqlDataSource.DataSourceMode property is set to the SqlDataSourceMode.DataSet value. The erload:System.Web.UI.WebControls.SqlDataSourceView.Select method returns a System.Data.IDataReader object if the SqlDataSource.DataSourceMode property is set to the SqlDataSourceMode.DataReader value. Close the System.Data.IDataReader object when you have finished reading the data.

Before the SqlDataSource.Select(System.Web.UI.DataSourceSelectArguments) operation is performed, the SqlDataSourceView.OnSelecting(SqlDataSourceSelectingEventArgs) method is called to raise the SqlDataSource.Selecting event. You can handle this event to examine the values of the parameters and to perform any processing before the SqlDataSource.Select(System.Web.UI.DataSourceSelectArguments) operation.

After the SqlDataSource.Select(System.Web.UI.DataSourceSelectArguments) operation completes, the SqlDataSourceView.OnSelected(SqlDataSourceStatusEventArgs) method is called to raise the SqlDataSource.Selected event. You can handle this event to examine any return values and error codes and to perform any post-processing.

If the SqlDataSource.DataSourceMode property is set to SqlDataSourceMode.DataSet and caching is enabled, the System.Web.UI.WebControls.SqlDataSource object retrieves data from and saves data to the cache during the SqlDataSource.Select(System.Web.UI.DataSourceSelectArguments) operation. The cache is created, discarded, or refreshed based on the caching behavior that is specified by the combination of the SqlDataSource.CacheDuration and SqlDataSource.CacheExpirationPolicy properties.

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 of data to be verified by the security configurations for the database, do not use caching.

If the SqlDataSource.DataSourceMode property is set to SqlDataSourceMode.DataSet and a SqlDataSource.FilterExpression property has been specified, the filter expression is evaluated with any supplied SqlDataSource.FilterParameters properties and the resulting filter is applied to the list of data during the SqlDataSource.Select(System.Web.UI.DataSourceSelectArguments) operation.

The SqlDataSource.Select(System.Web.UI.DataSourceSelectArguments) method delegates to the erload:System.Web.UI.WebControls.SqlDataSourceView.Select method of the System.Web.UI.WebControls.SqlDataSourceView object that is associated with the System.Web.UI.WebControls.SqlDataSource control. To perform a data retrieval operation, the System.Web.UI.WebControls.SqlDataSourceView builds a System.Data.Common.DbCommand object by using the SqlDataSource.SelectCommand text and any associated SqlDataSource.SelectParameters values, and then executes the System.Data.Common.DbCommand against the underlying database.

Note:

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

Requirements

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