Retrieves data from the underlying database using the SqlDataSourceView.SelectCommand SQL string and any parameters that are in the SqlDataSourceView.SelectParameters collection.
- arguments
- A System.Web.UI.DataSourceSelectArguments object used to request operations on the data beyond basic data retrieval.
An IEnumerable list of data rows.
The System.Web.UI.WebControls.SqlDataSourceView class implements the inherited SqlDataSourceView.ExecuteSelect(System.Web.UI.DataSourceSelectArguments) method to retrieve data from a database. Page developers and data-bound control authors do not call the SqlDataSourceView.ExecuteSelect(System.Web.UI.DataSourceSelectArguments) method directly; instead, use the publicly exposed SqlDataSource.Select(System.Web.UI.DataSourceSelectArguments) method.
Before the data retrieval is performed, the SqlDataSourceView.OnSelecting(SqlDataSourceSelectingEventArgs) method is called to raise the SqlDataSourceView.Selecting event. You can handle this event to examine the values of the parameters and to perform any preprocessing before data is retrieved.
To perform the operation, the System.Web.UI.WebControls.SqlDataSourceView object builds a System.Data.Common.DbCommand object using the SqlDataSource.SelectCommand text and any associated SqlDataSource.SelectParameters, and executes it against the underlying database. After the 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, error codes, and perform any post-processing.
The SqlDataSourceView.ExecuteSelect(System.Web.UI.DataSourceSelectArguments) method returns a System.Data.DataView object if the SqlDataSource.DataSourceMode is set to SqlDataSourceMode.DataSet, or a System.Data.IDataReader object if the SqlDataSource.DataSourceMode is set to SqlDataSourceMode.DataReader. Close the System.Data.IDataReader object when you have finished reading the data.
If the SqlDataSource.DataSourceMode is set to SqlDataSourceMode.DataSet and caching is enabled, the System.Web.UI.WebControls.SqlDataSourceView retrieves data from and saves data to the cache during the data operation. The cache is created, discarded, or refreshed based on the caching behavior specified by the combination of the SqlDataSource.CacheDuration and SqlDataSource.CacheExpirationPolicy properties.
When you are using client impersonation under 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 multiple users to access the data, and you want each retrieval to the data to be verified by the database's security configurations, do not use caching.
If the SqlDataSource.DataSourceMode is set to SqlDataSourceMode.DataSet and a SqlDataSourceView.FilterExpression has been specified, it is evaluated along with any supplied SqlDataSourceView.FilterParameters and the resulting filter is applied to the list of data during the data retrieval operation.