Click here to Skip to main content
15,891,926 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
Please help me.
I am Creating a dynamic tree using Asp.net,C# with Linq so i have problem to add the node of selecting node how adding?
Posted
Updated 7-Apr-11 4:11am
v2
Comments
dan!sh 7-Apr-11 4:46am    
You want to add new nodes under selected node? Please descride again nad what does LINQ plays in it?
kaival007 7-Apr-11 8:26am    
I want to add new node under selected node

1 solution

Basically you have to populate the parent level and then implement the OnTreeNodePopulate event. You might create the mark-up as:

XML
<asp:TreeView
    ID="tvRPM"
    runat="server"
    ClientIDMode="Static"
    EnableClientScript="true"
    ExpandDepth="0"
    PopulateNodesFromClient="true"
    ShowLines="true"
    OnTreeNodePopulate="PopulateNode"
    OnSelectedNodeChanged="tvRPM_SelectedNodeChanged">
    <NodeStyle ForeColor="Black" HorizontalPadding="3" VerticalPadding="3" />
    <HoverNodeStyle BackColor="#ffffcc" />
    <SelectedNodeStyle BackColor="#dddddd" BorderColor="DarkGray" BorderStyle="Dotted" BorderWidth="1" HorizontalPadding="5" VerticalPadding="3" />
</asp:TreeView>


and have a method that populates the parents on load. then , within the PopulateNode method you would create and populate the childnodes passing the unique id of the parent as a key.

The method signature of PopulateNode looks like:

protected void PopulateNode(Object sender, TreeNodeEventArgs e)


I leave it to you to research the means by which you populate each new node from this point. Note that there are several articles on CP that outline this process in detail: search for those first.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900