using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using System.Data;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.Drawing;

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

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void RadGridStandard_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath("~/App_Data/Nwind.mdb"));
        OleDbDataAdapter adapter = new OleDbDataAdapter();
        adapter.SelectCommand = new OleDbCommand("SELECT * FROM Customers", conn);
        DataTable myDataTable = new DataTable();
        conn.Open();
        try
        {
            adapter.Fill(myDataTable);
        }
        finally
        {
            conn.Close();
        }
        RadGridStandard.DataSource = myDataTable;

    }
    protected void RadGridStandard_DataBinding(object sender, EventArgs e)
    {
        for (int i = 0; i < RadGridStandard.PageSize; i++)
        {
            RadGridStandard.EditIndexes.Add(i);
        }
    }

    protected void RadGridStandard_ItemCreated(object sender, GridItemEventArgs e)
    {

        RadGridStandard.CellPadding = 0;

        foreach (GridDataItem item in RadGridStandard.MasterTableView.Items)
        {
            if (item != null)
            {
                for (int i = 2; i < RadGridStandard.MasterTableView.RenderColumns.Length; i++)
                {
                    GridColumn column = RadGridStandard.MasterTableView.RenderColumns[i];
                    if (item[column.UniqueName].Controls.Count > 0)
                    {
                        column.HeaderStyle.Width = 90;
                        //item[column.UniqueName].Style["Padding"] = "0";
                        item[column.UniqueName].CssClass = "GridItem";
                        item[column.UniqueName].BorderColor = Color.LightGray;
                        TextBox textBox = (item[column.UniqueName].Controls[0]) as TextBox;
                        if ((textBox != null))
                        {
                            textBox.ReadOnly = true;
                            textBox.Attributes.Add("class", "readOnly");
                            textBox.CssClass = "GridAltRow_WebBlue";
                            textBox.BorderStyle = BorderStyle.None;
                            textBox.Width = 90;
                        }
                    }
                }
            }
        }
    }
}