Data binding treeview

2 posts, 0 answers
  1. Tina
    Tina avatar
    130 posts
    Member since:
    Jul 2011

    Posted 02 Apr 2012 Link to this post

    How can I bind treeview using sqldatasource from code behind?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 02 Apr 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top