Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

tree childnode

Posted on 2013-02-05
3
Medium Priority
?
262 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:Seven price
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
AshwaniMunshi earned 2000 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:Seven price
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:Seven price
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

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

916 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