using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Reflection;
using Telerik.Web.UI;

public partial class _Default : System.Web.UI.Page
{





    protected void Page_Load(object sender, EventArgs e)
    {
        //    RadGrid1.MasterTableView.FilterExpression = "ReportsTo IS NULL";     
    }

    protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        //RadGrid1.DataSource = SqlDataSource1.Select(new DataSourceSelectArguments());

        List<Employee> employees = new List<Employee>();

        for (int i = 0; i < 5; i++)
        {
            employees.Add(new Employee(i, i.ToString() + "lName", i.ToString() + "fName", i.ToString() + "city", 2));
        }
        for (int i = 5; i < 10; i++)
        {
            employees.Add(new Employee(i, i.ToString() + "lName", i.ToString() + "fName", i.ToString() + "city", 4));
        }

        for (int i = 10; i < 15; i++)
        {
            employees.Add(new Employee(i, i.ToString() + "lName", i.ToString() + "fName", i.ToString() + "city", 9));
        }

        RadGrid1.DataSource = employees;

    }
    protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {

    }


    public class Employee
    {
        private int _EmployeeID;

        #region public properties
        public int EmployeeID
        {
            get { return _EmployeeID; }
            set { _EmployeeID = value; }
        }
        private string _LastName;

        public string LastName
        {
            get { return _LastName; }
            set { _LastName = value; }
        }
        private string _FirstName;

        public string FirstName
        {
            get { return _FirstName; }
            set { _FirstName = value; }
        }
        private string _City;

        public string City
        {
            get { return _City; }
            set { _City = value; }
        }
        private int _ReportsTo;

        public int ReportsTo
        {
            get { return _ReportsTo; }
            set { _ReportsTo = value; }
        }
        #endregion


        public Employee(int _ID, string _lName, string _fName, string _city, int _reportsTo)
        {
            _EmployeeID = _ID;
            _LastName = _lName;
            _FirstName = _fName;
            _City = _city;
            _ReportsTo = _reportsTo;

        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {       
        RadGrid1.ExportSettings.OpenInNewWindow = true;
        RadGrid1.ExportSettings.IgnorePaging = true;
        RadGrid1.ExportSettings.ExportOnlyData = true;
        RadGrid1.MasterTableView.HierarchyDefaultExpanded = true;
        RadGrid1.Rebind();
        RadGrid1.MasterTableView.ExportToExcel();
    }
}


