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

Bind datatable value as parent nodes to Treeview

1 Answer 127 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Swapnil
Top achievements
Rank 1
Swapnil asked on 04 Dec 2013, 11:00 AM
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

1 Answer, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 09 Dec 2013, 09:50 AM
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.
Tags
TreeView
Asked by
Swapnil
Top achievements
Rank 1
Answers by
Kate
Telerik team
Share this question
or