Export (0) Print
Expand All

IDataSource Interface

Represents an abstract data source that data-bound controls bind to.

Namespace:  System.Web.UI
Assembly:  System.Web (in System.Web.dll)

type IDataSource =  interface end

The IDataSource type exposes the following members.

Public methodGetViewGets the named data source view associated with the data source control.
Public methodGetViewNamesGets a collection of names representing the list of view objects associated with the IDataSource interface.

Public eventDataSourceChangedOccurs when a data source control has changed in some way that affects data-bound controls.

Public Extension MethodGetDefaultValuesGets the collection of the default values for the specified data source. (Defined by DynamicDataExtensions.)
Public Extension MethodGetMetaTableGets the metadata for a table in the specified data source object. (Defined by DynamicDataExtensions.)
Public Extension MethodTryGetMetaTableDetermines whether table metadata is available. (Defined by DynamicDataExtensions.)

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 implement the IDataSource interface when you want to implement your own custom ASP.NET data source control.

Any class that implements the IDataSource interface is a data source control. The IDataSource interface serves as the foundation for all ASP.NET data source controls and defines one of the fundamental data-binding architecture concepts with its two methods: the GetView method and the GetViewNames method. This concept is that all data source controls support one or more named views on their data. The data source view object is similar to the DataView abstraction in the System.Data namespace: a data-bindable, customized view of data for sorting, filtering, and other data operations that the view defines. At its core, a data source control does nothing more than retrieve views on data.

A data source control can have one or more associated data source view objects. Some data source controls, including those that represent relational databases such as SqlDataSource and AccessDataSource, support only one view. Other data source controls, including hierarchical data source controls such as SiteMapDataSource, support many views. The data source view defines the capabilities of a data source and the operations that it supports.

In summary, data source controls implement the IDataSource interface, support one or more named views on the data they represent, and always support data retrieval from the data source they represent. Data source controls always retrieve data on demand, such as when DataBind is called on a data bound control.

The following code example demonstrates how a class can implement the methods defined by the IDataSource interface to provide data to data-bound controls. The data source control in this example acts as a data source on a comma-separated value file, and can be used by any data-bound control to display comma-separated file data. This code example is part of a larger example provided for the DataSourceControl class.


.NET Framework




© 2014 Microsoft