protected void btnSave_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            try
            {
                Audit  audit = new Audit();
                string notes = null;
                if (ddlArc.SelectedIndex > 0)
                {
                    if (gvProducts.Rows.Count > 0)
                    {
                        int retrun = -1;
                        foreach (GridViewRow row in gvProducts.Rows)
                        {
                            Decimal  objtxtPrice      = -1;
                            DateTime?objtxtExpiryDate = null;
                            Int32    objlblProuctId   = Convert.ToInt32((row.FindControl("ProductId") as Label).Text); // get product id
                            if ((row.FindControl("txtPrice") as TextBox).Text.Trim() != "")
                            {
                                objtxtPrice = Convert.ToDecimal((row.FindControl("txtPrice") as TextBox).Text); // get entered Price
                            }
                            if ((row.FindControl("txtExpiryDate") as TextBox).Text.Trim() != "")
                            {
                                objtxtExpiryDate = DateTime.Parse((row.FindControl("txtExpiryDate") as TextBox).Text); // get selected expiry date
                            }
                            if (objtxtPrice > -1 && objtxtExpiryDate != null)
                            {
                                db     = new LinqToSqlDataContext();
                                retrun = db.USP_SaveARCProductPrice(Convert.ToInt32(ddlArc.SelectedValue), objlblProuctId, objtxtPrice, objtxtExpiryDate, Convert.ToString(Session[enumSessions.User_Id.ToString()])); // pass all values to save
                            }
                            notes += "Product: " + objlblProuctId + ", Price: " + objtxtPrice + ", Date: " + objtxtExpiryDate + ", ";
                        }

                        if (retrun == 0)
                        {
                            string script = "alertify.alert('" + ltrProdPriceUpdate.Text + "');";
                            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
                        }
                        else
                        {
                            string script = "alertify.alert('" + ltrEntered.Text + "');";
                            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
                        }

                        BindProducts(Convert.ToInt32(ddlArc.SelectedValue.ToString())); // Bind updated price/date with Gridview
                    }
                    else
                    {
                        string script = "alertify.alert('" + ltrNoProdMap.Text + "');";
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
                    }
                }

                else
                {
                    string script = "alertify.alert('" + ltrSelectARC.Text + "');";
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", script, true);
                }
                audit.Notes     = "ARC: " + ddlArc.SelectedItem.ToString() + ", " + notes;
                audit.UserName  = Session[enumSessions.User_Name.ToString()].ToString();
                audit.ChangeID  = Convert.ToInt32(enumAudit.Manage_ARC_Product_Price);
                audit.CreatedOn = DateTime.Now;
                if (Request.ServerVariables["LOGON_USER"] != null)
                {
                    audit.WindowsUser = Request.ServerVariables["LOGON_USER"];
                }
                audit.IPAddress = Request.UserHostAddress;
                db.Audits.InsertOnSubmit(audit);
                db.SubmitChanges();
            }
            catch (Exception objException)
            {
                db = new CSLOrderingARCBAL.LinqToSqlDataContext();
                db.USP_SaveErrorDetails(Request.Url.ToString(), "btnSave_Click", Convert.ToString(objException.Message), Convert.ToString(objException.InnerException), Convert.ToString(objException.StackTrace), "", HttpContext.Current.Request.UserHostAddress, false, Convert.ToString(HttpContext.Current.Session[enumSessions.User_Id.ToString()]));
            }
            finally
            {
                if (db != null)
                {
                    db.Dispose();
                }
            }
        }
    }