Assembly: System.Web (in System.Web.dll)
The method is automatically called during the PreRender phase of the page life cycle. It is called by data-bound controls that have been attached to a SqlDataSource control through their DataSourceID property.
The Select method returns a DataView object if the DataSourceMode property is set to the DataSet value. The Select method returns 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 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 processing before the operation.
If the DataSourceMode property is set to SqlDataSourceMode.DataSet and caching is enabled, the SqlDataSource object 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.
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 DataSourceMode property is set to SqlDataSourceMode.DataSet and a FilterExpression property has been specified, the filter expression is evaluated with any supplied FilterParameters properties and the resulting filter is applied to the list of data during the operation.
The 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 by using the SelectCommand text and any associated SelectParameters values, and then executes the DbCommand against the underlying database.
The following examples show how to programmatically call the method and set values based on the result of the query. The following example shows the declarative code for the Web controls.
The following example shows how to programmatically call the method. The SqlDataSource control returns an integer. The value of the integer is used to set the text of a Label control and to determine whether to display a HyperLink control.
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.