Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

HierarchicalDataBoundControlAdapter Class

Note: This class is new in the .NET Framework version 2.0.

Customizes the behavior of a HierarchicalDataBoundControl object with which this control adapter is associated, for specific browser requests.

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

public class HierarchicalDataBoundControlAdapter : WebControlAdapter
public class HierarchicalDataBoundControlAdapter extends WebControlAdapter
public class HierarchicalDataBoundControlAdapter extends WebControlAdapter

The HierarchicalDataBoundControlAdapter class adapts the associated HierarchicalDataBoundControl control to modify the default markup or behavior for a specific browser. You can extend the HierarchicalDataBoundControlAdapter class to further customize rendering of the HierarchicalDataBoundControl control.

A HierarchicalDataBoundControl control is bound to a data source and generates its user interface (or child control hierarchy, typically), by enumerating the items in the data source to which it is bound. For more information on hierarchical data-bound controls, see HierarchicalDataBoundControl.

Control adapters are.NET components that manage one or more stages in the life cycle of a control for a specific browser. Extending the HierarchicalDataBoundControlAdapter class provides access to the life-cycle stages of the HierarchicalDataBoundControl control. For more information, see Architectural Overview of Adaptive Control Behavior.

The initial request for an adapter causes the .NET Framework to search for a mapped adapter for the control, given the characteristics of the requesting browser. Browser definition files are used by the HttpBrowserCapabilities class to identify the characteristics of the client browser and map the adapter to the browser type.

The following code example shows how to extend the HierarchicalDataBoundControlAdapter class to render a hierarchical TreeView control that is bound to an XmlDataSource object.

This code example contains four objects:

  • An adapter derived from the HierarchicalDataBoundControlAdapter class.

  • The .aspx file that incorporates the TreeView control and device-specific content.

  • A browser file to link the adapter to a device type.

  • An XML file that contains a hierarchical list of employees.

This code example consists of four code segments. The first code segment demonstrates how to extend the HierarchicalDataBoundControlAdapter class.

using System;
using System.Web;
using System.Web.UI;
using System.Security.Permissions;

namespace Contoso
        Level = AspNetHostingPermissionLevel.Minimal)]
        Level = AspNetHostingPermissionLevel.Minimal)]
    public class HierarchicalTreeViewAdapter :
        // Return a strongly-typed TreeView control for adapter.
        protected new System.Web.UI.WebControls.TreeView Control
                return (System.Web.UI.WebControls.TreeView)base.Control;

        // Verify the DataSourceID property is set prior to binding data.
        protected override void PerformDataBinding()
            if (Control.DataSourceID != null)

The second code segment demonstrates how to declare a TreeView to bind to an XML data source.

<%@ page language="c#" %>

<head runat="server">
    <title>HierarchicalDataBoundControl Adapter</title>
    <form id="Form1" runat="server">
        <asp:TreeView ID="TreeView1" 

                    DataMember="employees" Text="Employees"/>
                    DataMember="employee" TextField="id" />
                    DataMember="name" TextField="fullname" />
        <asp:XmlDataSource ID="XmlDataSource1"  
            DataFile="employees.xml" />
        <br />

The third code segment shows how to link the TreeView control to the custom adapter for browsers running on Windows CE.

    <browser refID="WinCE">
            <adapter controlType="System.Web.UI.WebControls.TreeView" 
                adapterType="Contoso.HierarchicalTreeViewAdapter" />
    <browser refID="IE">
            <adapter controlType="System.Web.UI.WebControls.TreeView" 
                adapterType="Contoso.HierarchicalTreeViewAdapter" />

The final code segment provides the XML data that the TreeView control binds to.

<?xml version="1.0" encoding="utf-8" ?>
    <employee id="100001">
        <name fullName="Panduro, Stig" />
    <employee id="100002">
        <name fullName="Haas, Jonathan" />
    <employee id="100003">
        <name fullName="Pearson, Simon" />

  • AspNetHostingPermission  for verifying at compilation time that the immediate caller has permission to call into the HierarchicalDataBoundControlAdapter class. Associated enumeration: Minimal
  • AspNetHostingPermission  for verifying that any class derived from the HierarchicalDataBoundControlAdapter class has at least the Minimal trust level. Associated enumeration: Minimal


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

© 2015 Microsoft