Tree style with XML data : TreeView « ASP.net Controls « ASP.NET Tutorial






<%@ page language="VB" %>

<script runat="server">

</script>

<html>
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form runat="server">
        <asp:treeview id="TreeView1" 
                      runat="server" 
                      font-underline="False" 
                      datasourceid="XmlDataSource1"
                      font-names="Tahoma" 
                      font-size="8pt" 
                      font-italic="False" 
                      font-bold="False" 
                      imageset="XP_Explorer"
                      forecolor="Black" 
                      nodeindent="15" 
                      autogeneratebindings="False">
            <selectednodestyle backcolor="#B5B5B5" 
                               font-underline="False" 
                               font-italic="False"
                               font-bold="False">
            </selectednodestyle>
            <hovernodestyle forecolor="#6666AA" 
                            font-underline="True" 
                            font-italic="False" 
                            font-bold="False">
            </hovernodestyle>
            <bindings>
                <asp:treenodebinding value="My Bookstore" depth="0" text="My Bookstore">
                </asp:treenodebinding>
                <asp:treenodebinding datamember="genre" textfield="name" depth="1">
                </asp:treenodebinding>
                <asp:treenodebinding datamember="book" textfield="isbn" depth="2">
                </asp:treenodebinding>
            </bindings>
            <parentnodestyle font-underline="False" font-italic="False" font-bold="False">
            </parentnodestyle>
            <leafnodestyle font-underline="False" font-italic="False" font-bold="False">
            </leafnodestyle>
            <nodestyle forecolor="Black" 
                       verticalpadding="2" 
                       horizontalpadding="2" 
                       font-underline="False"
                       font-names="Tahoma" 
                       font-size="8pt" 
                       font-italic="False" 
                       font-bold="False">
            </nodestyle>
            <rootnodestyle font-underline="False" font-italic="False" font-bold="False">
            </rootnodestyle>
        </asp:treeview>
        <asp:xmldatasource id="XmlDataSource1" runat="server" datafile="Data.xml">
        </asp:xmldatasource>

    </form>
</body>
</html>

File: Data.xml

<?xml version="1.0" standalone="yes"?>
<bookstore>
  <genre name="fiction">
    <book ISBN="10-000000-001">
      <title>title 1</title>
      <price>12.95</price>
      <comments>
        <userComment rating="4">
           comment 1
        </userComment>
        <userComment rating="2">
           comment 2
        </userComment>
      </comments>
    </book>
  </genre>
</bookstore>








3.27.TreeView
3.27.1.Using the TreeView Control
3.27.2.Selecting a TreeView node.
3.27.3.Displaying TreeView check boxes.
3.27.4.Displaying a Site Map with a TreeView control.
3.27.5.Binding to an XML File
3.27.6.Complex tree view
3.27.7.Tree view style
3.27.8.Tree style with XML data
3.27.9.Tree view event