Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
130
Adding Grand Child in Web Data Tree through cs code
posted

I want to add grand child in web data tree through cs code,not through html

I have created node and add child to them but i want to add sub items(grand child)

Can some one please guide me that how can I add sub child(grand child) in web data tree?

Here is my code

DataTreeNode node = new DataTreeNode();
node.Text = "Dummy";
this.WebDataTree1.Nodes.Add(node);
node.Nodes.Add("Dummy Child");
node.Nodes.Add("Dummy Child 2");

Parents
No Data
Reply
  • 1300
    Verified Answer
    Offline posted

    Hello Zeshan,

    After investigating this further, I determined that in order to add grandchild node, the child should be added as a node itself. Your requirement could be achieved by adding the following lines of code to the method bound to the “onInit” event of the WebDataTree:

    protected void WebDataTree1_Init(object sender, EventArgs e)

        {

            DataTreeNode rootNode = new DataTreeNode();

            rootNode.Text = "Root";

            this.WebDataTree1.Nodes.Add(rootNode);

            DataTreeNode childNode = new DataTreeNode();

            childNode.Text = "Child Node";

            rootNode.Nodes.Add(childNode);

            DataTreeNode grandChildNode = new DataTreeNode();

            grandChildNode.Text = "Grandchild Node";

            childNode.Nodes.Add(grandChildNode);

        }

    Below I am attaching a sample, demonstrating the described behavior. Please test it on your side and let me know if you need any further information regarding this matter.

    Regards,

    Monika Kirkova,

    Infragistics

    WebDataTreeSubNode.zip

Children
No Data