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

asked on

tree childnode

For some reason I can only choose the first child node but not the rest.
for example I have 3 childnode folders and they are listed by date. But when I try to change the second and third child node I cannot. I try to split the string and yet I still cannot.  Only the first ChildNode it picks up and skips the rest.


 For Each subDir As DirectoryInfo In subDirs
            Dim d As DateTime
            Dim provider As IFormatProvider = System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat
            If (DateTime.TryParseExact(subDir.ToString, "MMddyyyy", provider, DateTimeStyles.None, d)) Then
                Dim subDir2 As String = d.ToString("MMMM dd, yyyy")
                Dim s As String = subDir2 & "~"
                Dim words = s.Split(New Char() {"~"c})
                thisDirNode.ChildNodes.Add(RecurseNodes(subDir))
                For Each word In words
                    thisDirNode.ChildNodes(0).Text = subDir2.ToString
                Next word
           
            End If
ASKER CERTIFIED SOLUTION
Avatar of AshwaniMunshi
AshwaniMunshi

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

Ok I see the problem . the above code did not work. when I am trying to rename each childnode by date it only writes the last one to the first node.

in my response.write i get.
January 02, 2013January 08, 2013February 05, 2013

but in my nodes I only get the last date which shows up in folder 01022013

how can I get the dates to show on all 3 folders.

 For Each subDir As DirectoryInfo In thisDir.GetDirectories()
           
            If (DateTime.TryParseExact(subDir.ToString, "MMddyyyy", provider, DateTimeStyles.None, d)) Then
                Dim subDir2 As String = d.ToString("MMMM dd, yyyy")
              
                Dim subNode As New TreeNode(thisDir.Name)
                subNode.Value = thisDir.FullName

                If subDir.GetDirectories().Length > 0 Or subDir.GetFiles().Length > 0 Then
                    '       For Each word In words
                    Dim s As String = subDir2 & "~"
                    Dim words = s.Split(New Char() {"~"c})
                    thisDirNode.ChildNodes.Add(RecurseNodes(subDir))
                    thisDirNode.ChildNodes(0).Text = subDir2.ToString
                    Response.Write(subDir2)
                End If

Open in new window

ScreenHunter-07-Feb.-06-10.45.jpg
I had to add a count on the page load not in the fucntion and it seem to work. Thanks for participating.