protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["UserName"] == null) { Response.Redirect("FrmLogin.aspx"); } // ViewState["Flag"] = "MD"; DT = new DataTable(); ViewState["Flag"] = Request.QueryString["Flag"].ToString(); if (Convert.ToString(ViewState["Flag"]) == "AD") { txtproductcode.Text = cp.GETMAX(Session["BRCD"].ToString()); txtintre.Text = cp.GETMAX11(Session["BRCD"].ToString()); TXTPRODUCTNAME.Focus(); btnSubmit.Visible = true; btnclear.Visible = true; txtproductcode.Enabled = false; txtintre.Enabled = false; btnSubmit.Text = "Submit"; } if (Convert.ToString(ViewState["Flag"]) == "MD") { txtproductcode.Focus(); btnSubmit.Visible = false; txtintre.Enabled = false; btnSubmit.Text = "Modify"; } else if (Convert.ToString(ViewState["Flag"]) == "DL") { txtproductcode.Focus(); btnclear.Visible = true; txtintre.Enabled = false; btnSubmit.Text = "Delete"; } else if (Convert.ToString(ViewState["Flag"]) == "VW") { txtproductcode.Focus(); BOOL(); btnSubmit.Visible = false; btnclear.Visible = true; btnSubmit.Text = "View"; //For Disbling all Controls btnclear.Visible = false; EnableDisable(true); } } }
protected void lnkAdd_Click(object sender, EventArgs e) { try { ViewState["Flag"] = "AD"; btnSubmit.Text = "Submit"; txtproductcode.Text = cp.GETMAX(Session["BRCD"].ToString()); txtintre.Text = cp.GETMAX11(Session["BRCD"].ToString()); TXTPRODUCTNAME.Focus(); btnSubmit.Visible = true; btnclear.Visible = true; txtproductcode.Enabled = false; txtintre.Enabled = false; } catch (Exception Ex) { ExceptionLogging.SendErrorToText(Ex); } }