A data source control interacts with the data-bound controls and hides the complex data binding processes. These are the tools that provide data to the data bound controls and support execution of operations like insertions, deletions, sorting, and updates.
Each data source control wraps a particular data provider-relational databases, XML documents, or custom classes and helps in:
- Managing connection
- Selecting data
- Managing presentation aspects like paging, caching, etc.
- Manipulating data
There are many data source controls available in ASP.NET for accessing data from SQL Server, from ODBC or OLE DB servers, from XML files, and from business objects.
Based on type of data, these controls could be divided into two categories:
- Hierarchical data source controls
- Table-based data source controls
The data source controls used for hierarchical data are:
- XMLDataSource – It allows binding to XML files and strings with or without schema information.
- SiteMapDataSource – It allows binding to a provider that supplies site map information.
The data source controls used for tabular data are:
|Data source controls||Description|
|SqlDataSource||It represents a connection to an ADO.NET data provider that returns SQL data, including data sources accessible via OLEDB and QDBC.|
|ObjectDataSource||It allows binding to a custom .Net business object that returns data.|
|LinqdataSource||It allows binding to the results of a Linq-to-SQL query (supported by ASP.NET 3.5 only).|
|AccessDataSource||It represents connection to a Microsoft Access database.|
Data Source Views
Data source views are objects of the DataSourceView class. Which represent a customized view of data for different data operations such as sorting, filtering, etc.
The DataSourceView class serves as the base class for all data source view classes, which define the capabilities of data source controls.
The following table provides the properties of the DataSourceView class:
|CanDelete||Indicates whether deletion is allowed on the underlying data source.|
|CanInsert||Indicates whether insertion is allowed on the underlying data source.|
|CanPage||Indicates whether paging is allowed on the underlying data source.|
|CanRetrieveTotalRowCount||Indicates whether total row count information is available.|
|CanSort||Indicates whether the data could be sorted.|
|CanUpdate||Indicates whether updates are allowed on the underlying data source.|
|Events||Gets a list of event-handler delegates for the data source view.|
|Name||Name of the view.|
The following table provides the methods of the DataSourceView class:
|CanExecute||Determines whether the specified command can be executed.|
|ExecuteCommand||Executes the specific command.|
|ExecuteDelete||Performs a delete operation on the list of data that the DataSourceView object represents.|
|ExecuteInsert||Performs an insert operation on the list of data that the DataSourceView object represents.|
|ExecuteSelect||Gets a list of data from the underlying data storage.|
|ExecuteUpdate||Performs an update operation on the list of data that the DataSourceView object represents.|
|Delete||Performs a delete operation on the data associated with the view.|
|Insert||Performs an insert operation on the data associated with the view.|
|Select||Returns the queried data.|
|Update||Performs an update operation on the data associated with the view.|
|OnDataSourceViewChanged||Raises the DataSourceViewChanged event.|
|RaiseUnsupportedCapabilitiesError||Called by the RaiseUnsupportedCapabilitiesError method to compare the capabilities requested for an ExecuteSelect operation against those that the view supports.|