using System;
using System.Data;
using System.Configuration;
using System.Collections;
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 System.Data.OleDb;
using Telerik.Web.UI;

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

    protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
    {
        OleDbConnection MyOleDbConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" +
        Server.MapPath("~/App_Data/Nwind.mdb"));
        OleDbDataAdapter MyOleDbDataAdapter = new OleDbDataAdapter();
        MyOleDbDataAdapter.SelectCommand = new OleDbCommand("SELECT TOP 10 CustomerID,CompanyName, ContactName FROM Customers", MyOleDbConnection);
        DataTable myDataTable;
        if (Session["DataSource"] != null)
        {
            myDataTable = (DataTable)Session["DataSource"];
        }
        else
        {
            myDataTable = new DataTable();
            MyOleDbConnection.Open();
            try
            {
                MyOleDbDataAdapter.Fill(myDataTable);
            }
            finally
            {
                MyOleDbConnection.Close();
            }
            myDataTable.PrimaryKey = new DataColumn[] { myDataTable.Columns["CustomerID"] };
            Session["DataSource"] = myDataTable;
        }
        RadGrid1.DataSource = myDataTable;
    }
}
