using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;

public partial class TelerikWebForm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            BindToDataSet(RadTreeView1);

        }
    }
    private static void BindToDataSet(RadTreeView treeView)
    {
        SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Employees",
                ConfigurationManager.ConnectionStrings["TelerikVSXConnectionString"].ConnectionString);

        DataSet links = new DataSet();

        adapter.Fill(links, "Employees");
        DataView view = links.Tables["Employees"].DefaultView;
        // To sort in ascending order:

       // view.Sort = "LastName" + " ASC";
        // To sort in descending order:
        view.Sort = "LastName" + " DESC";

        treeView.DataTextField = "LastName";
        treeView.DataFieldID = "EmployeeID";
        treeView.DataFieldParentID = "ReportsTo";

        treeView.DataSource = view;
        treeView.DataBind();
    }

}
