Create a dinamically treeview

2 posts, 1 answers
  1. Bruno
    Bruno avatar
    20 posts
    Member since:
    Feb 2012

    Posted 05 Mar 2012 Link to this post

    I wanna create the treeview data, and looks like this.

    -Past
        -Example1
                 - child1
                 - child2
        -Example2
                - child3
                - child4

    Until now i dont found any stuff about that, and i facing some problems to do that.
    Does anyone know how can i do that?
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 Mar 2012 Link to this post

    Hello,

    Try the following code.
    C#:
    protected void Page_Load(object sender, EventArgs e)
     {
      RadTreeView RadTreeView1 = new RadTreeView();
      RadTreeNode Past = new RadTreeNode();
      Past.Text = "Past";
      RadTreeNode Example1 = new RadTreeNode();
      Example1.Text = "Example1";
      RadTreeNode child1 = new RadTreeNode();
      child1.Text = "child1";
      RadTreeNode child2 = new RadTreeNode();
      child2.Text = "child2";
      RadTreeNode Example2 = new RadTreeNode();
      Example2.Text = "Example2";
      RadTreeNode child3 = new RadTreeNode();
      child3.Text = "child3";
      RadTreeNode child4 = new RadTreeNode();
      child4.Text = "child4";
      RadTreeView1.Nodes.Add(Past);
      Past.Nodes.Add(Example1);
      Past.Nodes.Add(Example2);
      Example1.Nodes.Add(child1);
      Example1.Nodes.Add(child2);
      Example2.Nodes.Add(child3);
      Example2.Nodes.Add(child4);
      form1.Controls.Add(RadTreeView1);
     }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top