Bind datatable value as parent nodes to Treeview

2 posts, 0 answers
  1. Swapnil
    Swapnil avatar
    96 posts
    Member since:
    Aug 2013

    Posted 04 Dec 2013 Link to this post

    Hi ,
    i have datatable which contain 3 company name and i want to add employees respective to that company below company name as childs(dynamically),
    My Code
    protected void Page_Load(object sender, EventArgs e)
      {
          int UserId = Convert.ToInt32(Session["UserId"].ToString());
          int RoleId = Convert.ToInt32(Session["RoleId"].ToString());
          dtParentNode = ObjGlobas.BindTreeView_Test(UserId,RoleId);
          RadTreeView1.DataSource = dtParentNode;
          RadTreeView1.DataFieldID = "CompId";
          RadTreeView1.DataTextField = "CompName";
          RadTreeView1.DataBind();
         BindToDataTable();
      }
    <telerik:RadTreeView ID="RadTreeView1" runat="server" Font-Names="Verdana">
               <DataBindings>
                   <telerik:RadTreeNodeBinding Expanded="True"></telerik:RadTreeNodeBinding>
               </DataBindings>
           </telerik:RadTreeView>

    how can i do that
    Thanks
  2. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 09 Dec 2013 Link to this post

    Hi Swapnil,

    To be able to establish  hierarchy with the RadTreeView control you will need to use the DataFieldParentID
    property of the control. Please take a look at the following help article to get more detailed information on how this can be accomplished - Binding to Hierarchical Data.

    Regards,
    Kate
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top