Solved

tree childnode

Posted on 2013-02-05
3
255 Views
Last Modified: 2013-02-06
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
0
Comment
Question by:sevensnake77
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
AshwaniMunshi earned 500 total points
ID: 38858943
Please refer the example below and see if it can help you:

For Each subtree As DirectoryInfo In directory.GetDirectories()
Dim subNode As New TreeNode(subtree.Name)
subNode.Value = subtree.FullName
Try
If subtree.GetDirectories().Length > 0 Or subtree.GetFiles().Length > 0 Then
subNode.SelectAction = TreeNodeSelectAction.SelectExpand
subNode.PopulateOnDemand = True
subNode.NavigateUrl = "#"
End If
Catch ex As Exception

End Try
node.ChildNodes.Add(subNode)
Next subtree
0
 
LVL 9

Author Comment

by:sevensnake77
ID: 38859992
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
0
 
LVL 9

Author Closing Comment

by:sevensnake77
ID: 38861343
I had to add a count on the page load not in the fucntion and it seem to work. Thanks for participating.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now