Export (0) Print
Expand All

TreeView.AutoGenerateDataBindings Property

Gets or sets a value indicating whether the TreeView control automatically generates tree node bindings.

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

member AutoGenerateDataBindings : bool with get, set
<asp:TreeView AutoGenerateDataBindings="True|False" />

Property Value

Type: System.Boolean
true to have the TreeView control automatically generate tree node bindings; otherwise, false. The default is true.

Tree node bindings define the relationship between a data item and the node it is binding to. When binding to a data source where each data item contains multiple properties (such as an XML element with several attributes), the TreeView control needs to know which data item property to bind to which TreeNode property. If the AutoGenerateDataBindings property is set to true, the TreeView control automatically generates default tree node bindings that set the Text property of the TreeNode object that is associated with the binding to the value that is returned by the ToString method of the data item.

NoteNote

The automatically generated tree node bindings are not added to the DataBindings collection.

In the case of an XML element, the value that is returned by the ToString method is the element name, which shows the underlying structure of the XML file, but is not very useful otherwise. To create a more useful tree, you must define your own tree node bindings by populating the DataBindings collection.

NoteNote

If you define a DataBindings collection, the TreeView control uses those values instead of automatically generated tree node bindings.

The value of this property is stored in view state.

This section contains two code examples. The first code example demonstrates how to disable automatic tree node binding generation by setting the AutoGenerateDataBindings property to false. The second code example provides sample site map data for the first code example.

The following code example demonstrates how to disable automatic tree node binding generation by setting the AutoGenerateDataBindings property to false. A DataBindings collection is then defined to establish the relationship between the data items in a SiteMapDataSource control and the nodes of the TreeView control. For this example to work correctly, you must copy the sample site map data, provided after this code example, to a file named Web.sitemap.

No code example is currently available or this language may not be supported.

The following code example provides sample site map data for the preceding example.

<siteMap>
    <siteMapNode title="Home" description="Home" url="default.aspx">
        <siteMapNode title="Products" description="Products" url="Products.aspx">
            <siteMapNode title="Computers" url="Computers.aspx"/>
            <siteMapNode title="Accessories" url="Accessories.aspx"/>     
        </siteMapNode>
    </siteMapNode>
</siteMap>

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft