This is a migrated thread and some comments may be shown as answers.

Dynamic nested nodes do not get attached to the nodes of treeview

1 Answer 44 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Effat
Top achievements
Rank 1
Effat asked on 25 Aug 2011, 06:47 AM
I am trying to create a tree view like on this page:

http://demos.telerik.com/aspnet-ajax/treeview/examples/functionality/templates/defaultcs.aspx

Here is my code:
CusTree.DataSource = tblData
CusTree.DataTextField = "CUSTOMER_NAME"
CusTree.DataValueField = "CUSTOMER_PREFIX"
CusTree.DataBind()
 
Dim nd As ITemplate = WipTree.NodeTemplate()
 
Dim nstdNode As New RadTreeNode
nstdNode.NodeTemplate = nd
 
For i As Integer = 1 To CusTree.Nodes.Count - 1
    CusTree.Nodes(i).Nodes.Add(nstdNode)
Next

As you can see I am trying to create it dynamically. I have two tree views: CusTree and WipTree. My problem is that when I add nstdNode (that contains the template node) to the CusTree nodes, it only shows the nstdNode appended to the last Node of CusTree. I am in a fix as what could be the problem. Can you please help me with this ASAP??

<telerik:RadTreeView ID="CusTree" runat="server" Skin="Outlook">
</telerik:RadTreeView>
 
<telerik:RadTreeView ID="WipTree" runat="server" Skin="Outlook">
    <NodeTemplate>
        <iframe id="frm" runat="server" src="http://google.com"></iframe>
    </NodeTemplate>
</telerik:RadTreeView>

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 30 Aug 2011, 02:44 PM
Hello Effat,

You can consult with the help topic Adding and editing Templates at Runtime. It looks like you are adding the nodes after you have already bound the TreeView.

Hope this is helpful.

Regards,
Plamen Zdravkov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
TreeView
Asked by
Effat
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or