This is a migrated thread and some comments may be shown as answers.

TreeView Directory Structure issue

0 Answers 42 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
CliffE
Top achievements
Rank 1
CliffE asked on 10 Jun 2010, 09:10 PM
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Telerik.Web.Examples.TreeView.DirectoryStructure.DefaultVB" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server">  
    <title>Patient Satisfaction Reports & Surveys</title> 
</head> 
<body> 
    <form id="form1" runat="server">  
    <div> 
        &nbsp;<telerik:RadTreeView ID="RadTreeView1" runat="server" OnNodeExpand="RadTreeView1_NodeExpand" DataFieldParentID="Description">  
            <Nodes> 
                <telerik:RadTreeNode runat="server" ExpandMode="ServerSideCallBack" 
                    Text="Patient Satisfaction Reports &amp; Surveys" Target="_parent">  
                </telerik:RadTreeNode> 
            </Nodes> 
            <DataBindings> 
                <telerik:RadTreeNodeBinding Target="_parent" ExpandMode="ServerSideCallBack" /> 
            </DataBindings> 
        </telerik:RadTreeView> 
        &nbsp;<telerik:RadScriptManager ID="RadScriptManager1" runat="server">  
        </telerik:RadScriptManager> 
        <br /> 
        <br /> 
        &nbsp;</div> 
    </form> 
</body> 
</html> 
I am having issues pulling data (folder&files) from a network server share.  Can someone look at my code behind and help?  I have also attached my source code as well.

Imports System  
Imports System.IO  
 
Imports Telerik.Web.UI  
 
Namespace Telerik.Web.Examples.TreeView.DirectoryStructure  
 
    Partial Public Class DefaultVB  
        Inherits System.Web.UI.Page  
 
        Private ReadOnly KnownExtensions As String() = New String() {"aspx", "asmx", "cs", "vb", "xml", "ascx", _  
         "jpg", "png", "gif", "html", "pdf"}  
 
        Private Sub BindTreeToDirectory(ByVal virtualPath As String, ByVal parentNode As RadTreeNode)  
            Dim physicalPath As String = Server.MapPath(virtualPath)  
            Dim directories As String() = Directory.GetDirectories(physicalPath)  
            For Each directory As String In directories  
                Dim node As New RadTreeNode(Path.GetFileName(directory))  
                node.Value = virtualPath + "/" + Path.GetFileName(directory)  
                node.ImageUrl = "~/TreeView/Img/Vista/folder.png" 
                node.ExpandMode = TreeNodeExpandMode.ServerSideCallBack  
                parentNode.Nodes.Add(node)  
            Next  
 
            Dim files As String() = Directory.GetFiles(physicalPath)  
            For Each file As String In files  
                Dim node As New RadTreeNode(Path.GetFileName(file))  
                Dim extension As String = Path.GetExtension(file).ToLower().TrimStart("."c)  
 
                If Array.IndexOf(KnownExtensions, extension) > -1 Then  
                    node.ImageUrl = "~/TreeView/Img/Vista/" + extension + ".png"  
                Else  
                    node.ImageUrl = "~/TreeView/Img/Vista/unknown.png" 
                End If  
 
                parentNode.Nodes.Add(node)  
            Next  
        End Sub  
 
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load  
            If Not Page.IsPostBack Then  
                Dim rootNode As New RadTreeNode("8000")  
                rootNode.Value = "2009" 
                rootNode.ImageUrl = "~/TreeView/Img/Vista/folder.png" 
                rootNode.Expanded = True 
                rootNode.SelectedImageUrl = True 
                rootNode.ExpandMode = TreeNodeExpandMode.ServerSideCallBack  
                RadTreeView1.Nodes.Add(rootNode)  
            End If  
        End Sub  
 
        Protected Sub RadTreeView1_NodeExpand(ByVal sender As Object, ByVal e As RadTreeNodeEventArgs)  
            BindTreeToDirectory(e.Node.Value, e.Node)  
        End Sub  
 
    End Class  
 
End Namespace 

No answers yet. Maybe you can help?

Tags
TreeView
Asked by
CliffE
Top achievements
Rank 1
Share this question
or