Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
815
VB.NET Example of Using the WebDataTree
posted

Hello,

I am looking for a VB.NET Example of using the webdatatree on the filesystem with load on demand.  I am trying to use it like the windows explorer for folders.

I love your products!!!

Thanks!!

Jack

Parents
  • 3147
    Suggested Answer
    posted

    Hi Jack,

    I'm glad that you like the products!

    I would recommend you to use manual load on demand for that case, here is a short sample which you can use as a starting point:

    <form id="form1" runat="server">
     <asp:ScriptManager ID="ScriptManager1" runat="server">
     </asp:ScriptManager>
     <ig:WebDataTree ID="WebDataTree1" runat="server" Height="300px" Width="200px">
     </ig:WebDataTree>
    </form>

    And code behind:

    Imports System.IO
    Imports Infragistics.Web.UI.NavigationControls


    Partial Class _Default
        Inherits System.Web.UI.Page

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not IsPostBack Then
                PopulateDirectory(WebDataTree1.Nodes, Server.MapPath("~/"))
            End If
        End Sub


        Protected Sub WebDataTree1_NodePopulate(ByVal sender As Object, ByVal e As Infragistics.Web.UI.NavigationControls.DataTreeNodeEventArgs) Handles WebDataTree1.NodePopulate
            PopulateDirectory(e.Node.Nodes, e.Node.DataPath)
        End Sub

        Sub PopulateDirectory(ByVal nodes As DataTreeNodeCollection, ByVal path As String)
            Dim info As DirectoryInfo
            info = New DirectoryInfo(path)

            For Each dir As DirectoryInfo In info.GetDirectories()
                Dim folderNode As DataTreeNode
                folderNode = New DataTreeNode()
                folderNode.Text = dir.Name
                folderNode.DataPath = String.Format("{0}/{1}", path, dir.Name)
                folderNode.IsEmptyParent = dir.GetDirectories().Length > 0
                nodes.Add(folderNode)
            Next
        End Sub
    End Class

     

    Hope that helps!

Reply Children
No Data