Solved

tree view in .net

Posted on 2009-07-01
1
202 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
A short film showing how OnPage and Connectwise integration works.

930 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

12 Experts available now in Live!

Get 1:1 Help Now