ASP.NET 3.5 and above only

ASP.NET TreeView - Binding With XmlDataSource

  • Book Title 1
    • Chapter 1
      • Section 1
      • Section 2
    • Chapter 2
      • Section 1
  • Book Title 2
    • Chapter 1
      • Section 1
      • Section 2
    • Chapter 2
      • Section 1
[ASPX]

            <obout:Tree ID="ObClassicTree" CssClass="vista" DataSourceID="XmlDataSource1"
                runat="server">
                <DataBindings>
                    <obout:NodeBinding 
                        DataMember="Book" 
                        ImageUrl="~/obout.ajax.ui/treeview/examples/img/vista_book.png" 
                        TextField="Title"
                        Expanded="true" />
                    <obout:NodeBinding 
                        DataMember="Chapter" 
                        ImageUrl="~/obout.ajax.ui/treeview/examples/img/vista_note.png"
                        TextField="Heading" />
                    <obout:NodeBinding 
                        DataMember="Section" 
                        ImageUrl="~/obout.ajax.ui/treeview/examples/img/vista_note.png"
                        TextField="Heading" />
                </DataBindings>
            </obout:Tree>
            <asp:XmlDataSource ID="XmlDataSource1" DataFile="~/obout.ajax.ui/treeview/examples/books.xml"
                    XPath="Books/Book" runat="server">
            </asp:XmlDataSource>
            
[books.xml]

            <?xml version="1.0" encoding="utf-8" ?>
            <Books>
              <Book Title="Book Title 1">
                <Chapter Heading="Chapter 1">
                  <Section Heading="Section 1">
                  </Section>
                  <Section Heading="Section 2">
                  </Section>
                </Chapter>
                <Chapter Heading="Chapter 2">
                  <Section Heading="Section 1">
                  </Section>
                </Chapter>
              </Book>
              <Book Title="Book Title 2">
                <Chapter Heading="Chapter 1">
                  <Section Heading="Section 1">
                  </Section>
                  <Section Heading="Section 2">
                  </Section>
                </Chapter>
                <Chapter Heading="Chapter 2">
                  <Section Heading="Section 1">
                  </Section>
                </Chapter>
              </Book>
            </Books>
            

"I really appreciate the way you helped and moreover the help came in such an electrifying speed.. Cool. Keep up the good work !!"

Atanu
Rebaca Technologies Pvt. Ltd.

Random testimonial   All testimonials