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 void Page_Load(object sender, EventArgs e)
    {

    }
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (true) //validated
        {
            switch (e.CommandName)
            {
                case "Update":
                    if (HiddenField1.Value == "false")
                    {
                        e.Canceled = true;
                        Session["savedIndex"] = e.Item.ItemIndex;
                        RadWindowManager1.RadConfirm("Employer validated. Do you want to continue?", "confirmEditBackFn", 350, 150, null, "Update Confirm");
                    }
                    break;
                case "UpdateConfirmed":
                    foreach (GridEditableItem item in RadGrid1.MasterTableView.GetItems(GridItemType.EditFormItem))
                    {
                        if (item.IsInEditMode && item.ItemIndex == (int)Session["savedIndex"])
                        {
                            item.FireCommandEvent("Update", String.Empty);
                        }
                    }
                    HiddenField1.Value = "false";
                    break;
                case "Delete":
                    if (HiddenField1.Value == "false")
                    {
                        e.Canceled = true;
                        Session["savedIndex"] = e.Item.ItemIndex;
                        RadWindowManager1.RadConfirm("Employer validated. Confirm delete?", "confirmDeleteBackFn", 350, 150, null, "Delete Confirm");
                    }
                    break;
                case "DeleteConfirmed":
                    {
                        RadGrid1.Items[(int)Session["savedIndex"]].FireCommandEvent("Delete", String.Empty);
                        HiddenField1.Value = "false";
                    }
                    break;
            }
        }
    }
}
