This documentation is archived and is not being maintained.

IHierarchicalDataSource.GetHierarchicalView Method

Gets the view helper object for the IHierarchicalDataSource interface for the specified path.

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

HierarchicalDataSourceView GetHierarchicalView (
	string viewPath
)
HierarchicalDataSourceView GetHierarchicalView (
	String viewPath
)
function GetHierarchicalView (
	viewPath : String
) : HierarchicalDataSourceView
Not applicable.

Parameters

viewPath

The hierarchical path of the view to retrieve.

Return Value

Returns a HierarchicalDataSourceView that represents a single view of the data at the hierarchical level identified by the viewPath parameter.

The IHierarchicalDataSource interface, like the IDataSource interface, defines a method that hierarchical data source controls use to retrieve a data source view. Like all DataSourceView helper objects that are associated with data source controls, a HierarchicalDataSourceView object defines the operations that the data source can perform with the underlying data. However, although data source controls that represent tabular data typically have only one named view, hierarchical data source controls support a 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 as the viewPath parameter.

The following code example demonstrates how to override the GetHierarchicalView method in a class that extends the HierarchicalDataSourceControl class to retrieve a strongly typed HierarchicalDataSourceView object for a unique hierarchical path. The FileSystemDataSource class's implementation of GetHierarchicalView retrieves a FileSystemDataSourceView object for a specified file system path. This code example is part of a larger example provided for the HierarchicalDataSourceControl class.

using System;
using System.Collections;
using System.IO;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

[AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Minimal)]
public class FileSystemDataSource : HierarchicalDataSourceControl, IHierarchicalDataSource
{
    public FileSystemDataSource() : base() {}

    // Return a strongly typed view for the current data source control.
    private FileSystemDataSourceView view = null;
    protected override HierarchicalDataSourceView GetHierarchicalView(string viewPath) {
        if (null == view) {
            view = new FileSystemDataSourceView(viewPath);
        }
        return view;
    }

    // The FileSystemDataSource can be used declaratively. To enable
    // declarative use, override the default implementation of
    // CreateControlCollection to return a ControlCollection that
    // you can add to.
    protected override ControlCollection CreateControlCollection() {
        return new ControlCollection(this);
    }
}

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0
Show: