Link to home
Start Free TrialLog in
Avatar of Seven price
Seven priceFlag for United States of America

asked on

custom tree view

Trying to render my server side code to look like my html example. Main problem, I want to have my files (( filePaths )) load also but this is not working in my for each loop.


HTML example
<ul id="browser" class="filetree treeview-famfamfam">
					<%--<li><span class="folder">State</span>
					<ul>
						<li><span class="folder"><asp:label runat="server" ID="Month1" Text="January_2013" ></asp:label></span>
							<ul id="folder21">
								<li><span class="file">01/04/13 - 01/07/13 <span style="color:red;">Current</span></span></li>
							</ul>
						</li>
									
			</ul>

Open in new window



server side code example
 If Not IsPostBack Then

            sb.Append("<ul id=""browser"" class=""filetree treeview-famfamfam"">")

            Dim StateList As String() = Directory.GetDirectories(Server.MapPath("statements/"))
            Dim filePaths As String() = Directory.GetFiles(Server.MapPath("statements"))
            For Each mylist As String In StateList
                sb.Append("<ul><li><span class=""folder"">").Append(mylist)
                GetDirectories(mylist)
                sb.Append("</span>")
                sb.Append("<ul>")
                sb.Append("<li><span class=""file"">" & "filePaths" & "<span style=""color:red;"">Current</span></span></li>")

            Next
            '   sb.Append("<ul>")
        End If
        sb.Append("</ul>")
        longlist.Text = (sb.ToString())


Private Sub GetDirectories(ByVal path As String)
        'use try catch since some directories may not allow you to read the subfolders eg:your antivruses Quarantine folder
        Try
            Dim directoryList As String() = System.IO.Directory.GetDirectories("statement")
            If directoryList.Length > 0 Then
                sb.Append("<ul>")
                For Each directory As String In directoryList
                    sb.Append("<li>").Append(directory)
                    GetDirectories(directory)
                    sb.Append("</li>")
                Next
                sb.Append("</ul>")
            End If

        Catch
        End Try
    End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rahul Agarwal
Rahul Agarwal
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Seven price

ASKER

tks