using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

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 Default : System.Web.UI.Page 
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        RadGrid1.ItemDataBound += new GridItemEventHandler(RadGrid1_ItemDataBound);
        RadGrid1.UpdateCommand += new GridCommandEventHandler(RadGrid1_UpdateCommand);
        RadGrid1.NeedDataSource += new GridNeedDataSourceEventHandler(RadGrid1_NeedDataSource);
    }

    void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        DataTable table = new DataTable();
        table.Columns.Add("ID");
        table.Columns.Add("Item");
        table.Columns.Add("Item1");
        for (int i = 1; i < 8; i++)
        {
            if (i > 1)
            {
                table.Rows.Add(i, string.Empty, string.Empty);
            }
            else
            {
                table.Rows.Add(i, "Item" + i.ToString(), "Item1" + i.ToString());
            }
        }
        RadGrid1.DataSource = table;
    }

    void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
    {

    }

    void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
        {
            string strFromTextBoxInTemplateColumn = ((e.Item as GridEditFormItem)["ItemColumn1"].FindControl("TextBox1") as TextBox).Text;
            string strFromTextBoxInBoundColumn = ((e.Item as GridEditFormItem)["ItemColumn"].Controls[0] as TextBox).Text;

            RadAjaxManager1.Alert("string from TextBox in TemplateColumn : " + strFromTextBoxInTemplateColumn + " string from TextBox in bound column: " + strFromTextBoxInBoundColumn);
        }
    }
}
