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 APNSoft.WebControls;

public partial class DataGrid_Templates_EditForm : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
                    
        //Define the method (Insert or Update)
        APNSoftDataGrid.EditFormMethodValues EditFormMethod = APNSoftDataGrid.EditFormMethod;


        //Insert method
        if (EditFormMethod == APNSoftDataGrid.EditFormMethodValues.Insert)
        {
            this.lblText.Text = "Enter the information below:";
            this.txtCustomerID.Enabled = true;
            this.lblSubmit.Text = @"<a href='javascript:InsertTheRow();'>Insert</a>";
        }


        //Update method
        if (EditFormMethod == APNSoftDataGrid.EditFormMethodValues.Update)
        {
            this.lblText.Text = "Edit the information below:";
            this.txtCustomerID.Enabled = false;

            //Restore fields
            this.txtCustomerID.Text = Server.HtmlDecode(APNSoftDataGrid.EditFormRow.Cells["CustomerID"].Value.ToString());
            this.txtCompanyName.Text = Server.HtmlDecode(APNSoftDataGrid.EditFormRow.Cells["CompanyName"].Value.ToString());
            this.txtContactName.Text = Server.HtmlDecode(APNSoftDataGrid.EditFormRow.Cells["ContactName"].Value.ToString());
            this.txtAddress.Text = Server.HtmlDecode(APNSoftDataGrid.EditFormRow.Cells["Address"].Value.ToString());

            this.lblSubmit.Text = @"<a href='javascript:UpdateTheRow();'>Update</a>";
        }

    }
}