Solved

tree childnode

Posted on 2013-02-05
3
257 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

825 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