Gets or sets a value indicating whether the TreeView control automatically generates tree node bindings.
Assembly: System.Web (in System.Web.dll)
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 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.
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.
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 theproperty 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 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.property to false. A
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>TreeView AutoGenerateBindings Example</title> </head> <body> <form id="form1" runat="server"> <h3>TreeView AutoGenerateBindings Example</h3> <!-- Set the AutoGenerateBindings property --> <!-- to false declaratively to allow for --> <!-- the user-defined Bindings collection. --> <asp:TreeView id="SiteTreeView" DataSourceID="SiteMapSource" AutoGenerateDataBindings="False" runat="server"> <DataBindings> <asp:TreeNodeBinding TextField="title" NavigateUrlField="url"/> </DataBindings> </asp:TreeView> <asp:SiteMapDataSource ID="SiteMapSource" runat="server"/> </form> </body> </html>
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>
Available since 2.0