This section contains seven code examples:
The first code example demonstrates how to set up the frames for the second code example.
The second code example demonstrates how to use declarative syntax to display static data in the TreeView control.
The third code example demonstrates how to bind the TreeView control to an XML data source.
The fourth code example provides sample XML data for the third code example.
The fifth code example demonstrates how to use the TreeView control for site navigation by binding it to a SiteMapDataSource control.
The sixth code example provides sample site map data for the fifth code example.
The seventh code example demonstrates how to populate the nodes in the TreeView control from the client.
The following code example demonstrates how to set up the frames for the following code example.
Visual Basic
TreeView Frameset Example
C#
TreeView Frameset Example
The following code example demonstrates how to use declarative syntax to display static data in the TreeView control. This example is used within the frame set of the preceding example to display a table of contents.
Visual Basic
<%@ Page Language="VB" %>
TreeView Declarative Syntax Example
C#
<%@ Page Language="C#" %>
TreeView Declarative Syntax Example
The following code example demonstrates how to bind the TreeView control to an XML data source. For this example to work correctly, you must copy the sample XML data, provided after this code example, to a file named Book.xml.
Visual Basic
<%@ Page Language="VB" %>
TreeView XML Data Binding Example
C#
<%@ Page Language="C#" %>
TreeView XML Data Binding Example
The following code example provides sample XML data for the preceding example.
The following code example demonstrates how to use the TreeView control for site navigation by binding it to a SiteMapDataSource 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.
Visual Basic
<%@ Page Language="VB" %>
TreeView AutoGenerateBindings Example
C#
<%@ Page Language="C#" %>
TreeView AutoGenerateBindings Example
The following code example provides sample site map data for the preceding code example.
The following code example demonstrates how to populate the nodes in the TreeView control from the client. When client-side node population is enabled, nodes are populated dynamically on the client, without the need to post back to the server.
Visual Basic
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
TreeView PopulateNodesFromClient Example