TreeView DataBindings : TreeView « Asp Control « ASP.Net

TreeView DataBindings

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" >
<head id="Head1" runat="server">
<title>TreeView DataBindings</title>
   <form id="form1" runat="server">
   <div id="container">
        <asp:TreeView ID="treeMain" 
              <asp:TreeNodeBinding DataMember="Category" TextField="Name" ImageUrlField="Icon" />
              <asp:TreeNodeBinding DataMember="Book" TextField="Title" />
           <RootNodeStyle HorizontalPadding="4" />
        <asp:XmlDataSource id="xmlSource" 
                           DataFile="Data.xml" XPath="/Books/Category"/>

File: Data.xml

<?xml version="1.0" encoding="utf-8" ?>
   <Category Name="Internet" Icon="images/small_iconInternet.gif">
      <Book Title="E-Business">
      <Book Title="Servers">
      <Book Title="Usability">

   <Category Name="Networking" Icon="images/small_iconNetworking.gif">
      <Book Title="Protocols">
      <Book Title="Security">


Related examples in the same category

1.A basic TreeView control
2.A TreeView control with the MSDN style applied to it
3.Binding a TreeView control to the Data.xml file
4.Add check boxes to leaf nodes (C#)
5.Add check boxes to leaf nodes (VB)
6.Applying custom images to the TreeView control
7.Expanding and collapsing the nodes of the TreeView control programmatically (C#)
8.Expanding and collapsing the nodes of the TreeView control programmatically (VB)
9.Expanding specific nodes programmatically
10.Expanding nodes programmatically using the Expanded property
11.Displaying database data with a TreeView control.
12.Using Populate On Demand and AJAX
13.Formatting the TreeView Control
14.Using Styles with the TreeView control.
15.Applying styles to different TreeView node levels.
16.Adding nodes programmatically to the TreeView control (C#)
17.Adding nodes programmatically to the TreeView control (VB)
18.Custom TreeView Control
19.Database tree
20.TreeView Populate On Demand
21.Test TreeView
22.Dynamic tree view
23.ParentNodeStyle in a TreeView
24.DirectoryInfo TreeView