Solved

tree view in .net

Posted on 2009-07-01
1
205 Views
Last Modified: 2013-11-07
Hi

I have created a tree view (see code section)

In which there is a root element called "$".

Now I want add nodes in this root column programatically. How can I do that in vb.net

<asp:TreeView ID = "tvMain" ExpandDepth = "0" PopulateNodesFromClient = "true" ShowLines = "true" 
                            ShowExpandCollapse = "true" runat = "server" CollapseImageUrl = "~/images/Folder.JPG" 
                            ExpandImageUrl = "~/images/FolderExpanded.JPG">
                            <Nodes>
                                 <asp:TreeNode Text="$" ImageUrl = "~/images/Folder.JPG">
                                     <asp:TreeNode Text="$" ImageUrl = "~/images/Folder.JPG">                                 
                                    </asp:TreeNode>
                                </asp:TreeNode>
                            </Nodes>
                        </asp:TreeView>

Open in new window

0
Comment
Question by:KaranGupta
1 Comment
 
LVL 20

Accepted Solution

by:
ddayx10 earned 500 total points
ID: 24752488
   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'just doing this so we dont add nodes every time posted back, completely optional
        'pick your poison from below
        If Not IsPostBack Then
            'Adds another child to the parent
            tvMain.Nodes(0).ChildNodes.Add(New TreeNode("$", "255", "~/images/Folder.JPG"))

            'Adds another node to the parent level
            tvMain.Nodes.Add(New TreeNode("$", "255", "~/images/Folder.JPG"))
        End If
    End Sub
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

713 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