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

public partial class _Default : System.Web.UI.Page
{
    public RadGrid RadGrid1 = new RadGrid();

    protected void Page_Init(object sender, System.EventArgs e)
    {
        RadGrid1.ID = "RadGrid1";
        RadGrid1.DataSourceID = "AccessDataSource1";
        RadGrid1.Width = Unit.Percentage(98);
        RadGrid1.PageSize = 5;
        RadGrid1.AllowPaging = true;
        RadGrid1.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;
        RadGrid1.AutoGenerateColumns = false;
        GridBoundColumn boundColumn = new GridBoundColumn();
        boundColumn.DataField = "EmployeeID";
        boundColumn.HeaderText = "Employee ID";
        RadGrid1.MasterTableView.Columns.Add(boundColumn);
        boundColumn = new GridBoundColumn();
        boundColumn.DataField = "LastName";
        boundColumn.HeaderText = "Last Name";
        RadGrid1.MasterTableView.Columns.Add(boundColumn);
        boundColumn = new GridBoundColumn();
        boundColumn.DataField = "FirstName";
        boundColumn.HeaderText = "First Name";
        RadGrid1.MasterTableView.Columns.Add(boundColumn);
        boundColumn = new GridBoundColumn();
        boundColumn.DataField = "Title";
        boundColumn.HeaderText = "Title";
        RadGrid1.MasterTableView.Columns.Add(boundColumn);
        boundColumn = new GridBoundColumn();
        boundColumn.DataField = "ReportsTo";
        boundColumn.HeaderText = "ReportsTo";
        RadGrid1.MasterTableView.Columns.Add(boundColumn);
        RadGrid1.Skin = "Web20";
        RadGrid1.ClientSettings.AllowExpandCollapse = true;
        RadGrid1.MasterTableView.HierarchyLoadMode = GridChildLoadMode.Client;
        RadGrid1.MasterTableView.HierarchyDefaultExpanded = true;
        RadGrid1.MasterTableView.DataKeyNames = new string[] { "EmployeeID", "ReportsTo" };
        RadGrid1.MasterTableView.SelfHierarchySettings.ParentKeyName = "ReportsTo";
        RadGrid1.MasterTableView.SelfHierarchySettings.KeyName = "EmployeeID";
        form1.Controls.Add(RadGrid1);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Assembly.GetAssembly(typeof(ScriptManager)).FullName.IndexOf("3.5") != -1)
        {
            RadGrid1.MasterTableView.FilterExpression = @"it[""ReportsTo""] = Convert.DBNull";
        }
        else
        {
            RadGrid1.MasterTableView.FilterExpression = "ReportsTo IS NULL";
        }

    }
  
}

