namespace APNSoft.DataGrid.Installation.Templates
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using APNSoft.WebControls;
public class EditForm : System.Web.UI.UserControl
{
//Declarations
protected System.Web.UI.WebControls.Label lblText;
protected System.Web.UI.WebControls.TextBox txtCustomerID;
protected System.Web.UI.WebControls.TextBox txtCompanyName;
protected System.Web.UI.WebControls.TextBox txtContactName;
protected System.Web.UI.WebControls.TextBox txtAddress;
protected System.Web.UI.WebControls.Label lblSubmit;
private void Page_Load(object sender, System.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>";
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
|