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

Data binding treeview

1 Answer 89 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Tina
Top achievements
Rank 1
Tina asked on 02 Apr 2012, 06:44 AM
How can I bind treeview using sqldatasource from code behind?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 02 Apr 2012, 07:06 AM
Hi Tina,

Try the following code to bind RadTreeView to SqlDataSource.

ASPX:
<telerik:RadTreeView ID="treeView" runat="server"></telerik:RadTreeView>

C#:
protected void Page_Load(object sender, EventArgs e)
   {
     SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Employees",ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
     DataSet links = new DataSet();
     adapter.Fill(links);
     treeView.DataTextField = "LastName";
     treeView.DataFieldID = "EmployeeID";
     treeView.DataFieldParentID = "ReportsTo";
     treeView.DataSource = links;
     treeView.DataBind();
   }

For more information please take a look into documentation and Demo.

Thanks,
Princy.
Tags
TreeView
Asked by
Tina
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or