Bearbeiten

IHierarchicalDataSource.GetHierarchicalView(String) Method

Definition

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

public:
 System::Web::UI::HierarchicalDataSourceView ^ GetHierarchicalView(System::String ^ viewPath);
public System.Web.UI.HierarchicalDataSourceView GetHierarchicalView (string viewPath);
abstract member GetHierarchicalView : string -> System.Web.UI.HierarchicalDataSourceView
Public Function GetHierarchicalView (viewPath As String) As HierarchicalDataSourceView

Parameters

viewPath
String

The hierarchical path of the view to retrieve.

Returns

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

Examples

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;

public class FileSystemDataSource :
    HierarchicalDataSourceControl, IHierarchicalDataSource
{
    private FileSystemDataSourceView view = null;

    public FileSystemDataSource() : base() { }

    protected override HierarchicalDataSourceView
        GetHierarchicalView(string viewPath)
    {
        view = new FileSystemDataSourceView(viewPath);
        return view;
    }
}
Imports System.Collections
Imports System.IO
Imports System.Runtime.InteropServices
Imports System.Security.Permissions
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls

Namespace Samples.AspNet

    Public Class FileSystemDataSource
        Inherits HierarchicalDataSourceControl

        Public Sub New()
        End Sub

        Private view As FileSystemDataSourceView = Nothing

        Protected Overrides Function GetHierarchicalView( _
            ByVal viewPath As String) As HierarchicalDataSourceView

            view = New FileSystemDataSourceView(viewPath)
            Return view
        End Function

    End Class

Remarks

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.

Applies to

See also