Provides a base class for data source controls that represent hierarchical data.
Assembly: System.Web (in System.Web.dll)
ASP.NET supports a controls data-binding architecture that enables Web server controls to bind to data and present it in a consistent fashion. Web server controls that bind to data are called data-bound controls, and the classes that facilitate binding are called data source controls. Data source controls can represent any data source: a file, a stream, a relational database, 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.
Data source controls that represent hierarchical data derive from the class, while data source controls that represent lists or tables of data derive from the DataSourceControl class. The class is the base implementation of the IHierarchicalDataSource interface, which defines a single method to retrieve hierarchical data source view objects associated with the data source control, GetHierarchicalView.
You can think of a data source control as the combination of the object and its associated views on the underlying data, called data source view objects. While data source controls that represent tabular data are typically associated with only one named view, the class supports a data source view for each level of hierarchical data that the data source control represents. The level of hierarchical data is identified by a unique hierarchical path, passed to the GetHierarchicalView method in the viewPath parameter. Each HierarchicalDataSourceView object defines the capabilities of a data source control for the hierarchical level represented, and performs operations such as insert, update, delete, and sort.
Data source controls are implemented as controls to enable declarative persistence and to optionally permit participation in state management. Data source controls have no visual rendering, and therefore do not support themes.
The following code example demonstrates how to extend the abstract class and the HierarchicalDataSourceView class, and implement the IHierarchicalEnumerable and IHierarchyData interfaces to create a hierarchical data source control that retrieves file system information. The FileSystemDataSource control enables Web server controls to bind to FileSystemInfo objects and display basic file system information. The FileSystemDataSource class in the example provides the implementation of the GetHierarchicalView method, which retrieves a FileSystemDataSourceView object. The FileSystemDataSourceView object retrieves the data from the underlying data storage, in this case the file system information on the Web server. For security purposes, file system information is displayed only if the data source control is being used in a localhost, authenticated scenario, and only starts with the virtual directory that the Web Forms page using the data source control resides in. Finally, two classes that implement IHierarchicalEnumerable and IHierarchyData are provided to wrap the FileSystemInfo objects that FileSystemDataSource uses.
The following code example demonstrates how to declaratively bind a TreeView control to file system data using the FileSystemDataSource example.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.