See Also: DataSourceControl Members
ASP.NET supports a control data-binding architecture that enables Web server controls to bind to data in a consistent fashion. Web server controls that bind to data are referred to as data-bound controls, and the classes that facilitate that binding are called data source controls. Data source controls can represent any data source: a relational database, a file, a stream, a business object, and so on. Data source controls present data in a consistent way to data-bound controls, regardless of the source or format of the underlying data.
You use the data source controls that are provided with ASP.NET, including System.Web.UI.WebControls.SqlDataSource, System.Web.UI.WebControls.AccessDataSource, and System.Web.UI.WebControls.XmlDataSource, to perform most Web development tasks. You use the base System.Web.UI.DataSourceControl class when you want to implement your own custom data source control.
While any class that implements the System.Web.UI.IDataSource interface is a data source control, most ASP.NET data source controls extend the abstract System.Web.UI.DataSourceControl class, which provides a base implementation of the System.Web.UI.IDataSource interface. The System.Web.UI.DataSourceControl class also provides an implementation of the System.ComponentModel.IListSource interface, which enables you to programmatically assign the data source control to the DataSource property of a data-bound control and return data to the control as a basic list.
Any ASP.NET control that derives from the System.Web.UI.WebControls.DataBoundControl class can bind to a data source control. When a System.Web.UI.WebControls.DataBoundControl is bound to a data source control, data binding is performed automatically at run time. You can also use data source controls with ASP.NET controls that expose a DataSource or DataSourceID property and support basic data binding, but are not derived from System.Web.UI.WebControls.DataBoundControl. When using these data-bound controls, you must explicitly call the DataBind method. For more information on data binding, see Accessing Data with ASP.NET.
You can think of a data source control as the combination of the System.Web.UI.DataSourceControl object and its associated lists of data, called data source views. Each list of data is represented by a System.Web.UI.DataSourceView object. Because the underlying data storage contains one or more lists of data, a System.Web.UI.DataSourceControl is always associated with one or more named System.Web.UI.DataSourceView objects. The System.Web.UI.IDataSource interface defines the methods that all data source controls use to interact with data source views: the DataSourceControl.GetViewNames method is used to enumerate the data source views currently associated with the data source control, and the DataSourceControl.GetView(string) method is used to retrieve a specific data source view instance by name.
You can also think of the data source control as two distinct interfaces that callers use to access data. The System.Web.UI.DataSourceControl class is the interface that page developers interact with directly when developing a Web Forms page, and the System.Web.UI.DataSourceView class is the interface that data-bound controls and data-bound control authors interact with. Because the System.Web.UI.DataSourceView object is available only at run time, any state persisted for the data source control or data source view must be exposed directly by the data source control.
There is no visual rendering of ASP.NET data source controls; they are implemented as controls so you can create them declaratively, and to optionally allow them to participate in state management. As a result, data source controls do not support visual features such as DataSourceControl.EnableTheming or DataSourceControl.SkinID.