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.InsertCommand += new GridCommandEventHandler(RadGrid1_InsertCommand);
        RadGrid1.UpdateCommand += new GridCommandEventHandler(RadGrid1_UpdateCommand);
        RadGrid1.ItemCreated += new GridItemEventHandler(RadGrid1_ItemCreated);
    }

    void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode && !(e.Item is GridEditFormInsertItem))
        {
            GridEditFormItem item = e.Item as GridEditFormItem;
            LinkButton button = item.FindControl("UpdateButton") as LinkButton;
            string customerID = item.ParentItem["CustomerID"].Text;
            string script = string.Format("confirmFn('Are you sure that you want to update the customer with ID = {0}', {1}); return false;", customerID, e.Item.ItemIndex);
            button.OnClientClick = script;
        }
        if (e.Item is GridEditFormInsertItem && e.Item.IsInEditMode)
        {
            GridEditFormItem item = e.Item as GridEditFormItem;
            LinkButton button = item.FindControl("PerformInsertButton") as LinkButton;

            string script = string.Format("confirmFn('Are you sure that you want to insert the new customer', {0}); return false;", e.Item.ItemIndex);
            button.OnClientClick = script;
        }
    }

    void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)
    {
       
    }

    void RadGrid1_InsertCommand(object source, GridCommandEventArgs e)
    {
        
    }
}
