System.Web.UI.WebControls Namespace SqlDataSource Class
.NET Framework version 2.0
Sets or retrieves the data retrieval mode that the SqlDataSource control uses to fetch data.
Inline |
<asp:SqlDataSource datasourcemode = enumValue ... > |
Script |
SqlDataSource.DataSourceMode [ = enumValue ] |
The property is read/write with a default value of DataSet.
Exception Type |
Condition |
ArgumentOutOfRangeException |
The DataSourceMode property is not one of the values defined in the SqlDataSourceMode. |
The data retrieval mode identifies how a SqlDataSource control retrieves data from the underlying database.
When the DataSourceMode property is set to the DataSet value, data is loaded into a DataSet object and stored in memory on the server. This enables scenarios where user interface controls, such as GridView, offer sorting, filtering, and paging capabilities.
When the DataSourceMode property is set to the DataReader value, data is retrieved by a IDataReader object, which is a forward-only, read-only cursor. The specific type of the IDataReader object depends on the NET data provider that the SqlDataSource uses, which is identified by the ProviderName property. By default, the SqlDataSource control uses the provider for Microsoft SQL Server, the System.Data.SqlClient, and the data reader is a SqlDataReader object.
If you change the DataSourceMode property, the DataSourceChanged event is raised, causing any controls that are bound to the SqlDataSource to rebind.
The value of the DataSourceMode property is stored in view state.
The following examples demonstrate how to set the DataSourceMode property.