New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Populating from XML

Populated via the LoadContentFile method

  • DesktopDesktop
    • Administrator
      • AppData
      • Contacts
      • Downloads
      • Documents
      • Favorites
      • Music
      • Pictures
      • Saved Games
      • Searches
      • Videos
    • My ComputerComputer
      • WebServer (\\10.0.0.80) (W:)
      • Local Disk (C:)
        • inetpub
          • AdminScripts

Bound to XmlDataSource

  • Desktop
    • Administrator
      • AppData
      • Contacts
      • Downloads
      • Documents
      • Favorites
      • Music
      • Pictures
      • Saved Games
      • Searches
      • Videos
    • Computer
      • WebServer (\\10.0.0.80) (W:)
      • Local Disk (C:)
        • inetpub
          • AdminScripts

You can seamlessly populate RadTreeView from XML.

  • Loading from XML file
    RadTreeView1.LoadContentFile("TreeView.xml");
    
  • Loading from XML string
    RadTreeView1.LoadXml("<Tree><Node Text="Books"/><Node Text="Music"/></Tree>");
    

You can also retrieve the current RadTreeView structure in XML format:

  • C#
    string xml = RadTreeView1.GetXml();
    
  • VB
    Dim xml as String = RadTreeView1.GetXml()
  • DefaultVB.aspx
  • DefaultVB.aspx.vb
  • TreeView.xml
<%@ Page AutoEventWireup="false" CodeFile="DefaultVB.aspx.vb" Inherits="TreeView.Examples.Programming.XmlFile.DefaultVB"Language="vb"  %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-containers">
        <div class="demo-container size-medium">
            <h2>Populated via the LoadContentFile method</h2>
            <telerik:RadTreeView RenderMode="Lightweight" ID="RadTreeView1" runat="server" Height="350px" Width="300" >
            </telerik:RadTreeView>
        </div>
        <div class="demo-container size-thin">
            <h2>Bound to XmlDataSource</h2>
            <telerik:RadTreeView RenderMode="Lightweight" ID="RadTreeView2" runat="server" DataSourceID="XmlDataSource1" Height="350px" Width="300" >
                <DataBindings>
                    <telerik:RadTreeNodeBinding DataMember="Node" TextField="Text" ImageUrlField="ImageUrl"
                        ExpandedField="Expanded"></telerik:RadTreeNodeBinding>
                </DataBindings>
            </telerik:RadTreeView>
        </div>
    </div>
    <asp:XmlDataSource runat="server" ID="XmlDataSource1" DataFile="TreeView.xml" XPath="/Tree/Node"></asp:XmlDataSource>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance