protected void btnSave_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                //errNumber = -1;
                try
                {
                    objBusinessClass        = new BusinessLayer.BusinessClass();
                    objML_CokeDynamicResult = new ML_CokeDynamicResult();



                    ML_CokeDynamic objML_CokeDynamic = null;// new ML_KeysPointChk();
                    objBusinessClass = new BusinessClass();

                    int CokeDynamicId = -1;
                    int obhReturn     = 0;

                    DateTime dtDateandTime = System.DateTime.Now;
                    if (ddlCokeType.SelectedIndex > 0)
                    {
                        foreach (GridViewRow row in grdCokeDynamicResult.Rows)
                        {
                            objML_CokeDynamic = new ML_CokeDynamic();
                            string txtCokeDynamicResult = string.Empty;



                            TextBox mytxtCokeDynamicResult = (TextBox)row.FindControl("txtCokeDynamicResult");
                            if (mytxtCokeDynamicResult != null)
                            {
                                txtCokeDynamicResult = mytxtCokeDynamicResult.Text;
                            }



                            Label lblCokeDynamicId = (Label)row.FindControl("lblCokeDynamicId");
                            if (lblCokeDynamicId != null)
                            {
                                CokeDynamicId = ML_Common.string2int(lblCokeDynamicId.Text);

                                objML_CokeDynamic = objBusinessClass.GetCokeDynamicByCokeDynamicId(CokeDynamicId);

                                objML_CokeDynamicResult = new ML_CokeDynamicResult();


                                objML_CokeDynamicResult.CokeDynamicResult = objML_CokeDynamic.CokeDynamic;


                                objML_CokeDynamicResult.CokeTypeId = ML_Common.string2int32(ML_Common.GetDropDownValue(ddlCokeType, true));
                                objML_CokeDynamicResult.CokeType   = ML_Common.string2string(ML_Common.GetDropDownValue(ddlCokeType, false));

                                objML_CokeDynamicResult.CokeSupplierId = ML_Common.string2int32(ML_Common.GetDropDownValue(ddlCokeSupplierName, true));
                                objML_CokeDynamicResult.CokeSupplier   = ML_Common.string2string(ML_Common.GetDropDownValue(ddlCokeSupplierName, false));

                                objML_CokeDynamicResult.AnalysisTypeId = ML_Common.string2int32(ML_Common.GetDropDownValue(ddlAnalysisType, true));
                                objML_CokeDynamicResult.AnalysisType   = ML_Common.string2string(ML_Common.GetDropDownValue(ddlAnalysisType, false));

                                objML_CokeDynamicResult.CokeDynamicId = objML_CokeDynamicResult.CokeDynamicId;
                                objML_CokeDynamicResult.CokeDynamic   = objML_CokeDynamic.CokeDynamic;


                                objML_CokeDynamicResult.FieldSize = objML_CokeDynamic.FieldSize;
                                objML_CokeDynamicResult.FieldUnit = objML_CokeDynamic.FieldUnit;
                                objML_CokeDynamicResult.FieldSpec = objML_CokeDynamic.FieldSpec;
                                objML_CokeDynamicResult.MinValue  = objML_CokeDynamic.MinValue;
                                objML_CokeDynamicResult.MaxValue  = objML_CokeDynamic.MaxValue;



                                //objML_CokeDynamicResult.CokeDynamicId = ML_Common.string2string(txtCokeDynamicResult);


                                objML_CokeDynamicResult.CokeTypeId = ML_Common.string2int32(ML_Common.GetDropDownValue(ddlCokeType, true));
                                objML_CokeDynamicResult.CokeType   = ML_Common.string2string(ML_Common.GetDropDownValue(ddlCokeType, false));

                                objML_CokeDynamicResult.CokeSupplierId = ML_Common.string2int32(ML_Common.GetDropDownValue(ddlCokeSupplierName, true));
                                objML_CokeDynamicResult.CokeSupplier   = ML_Common.string2string(ML_Common.GetDropDownValue(ddlCokeSupplierName, false));


                                objML_CokeDynamicResult.AnalysisTypeId = ML_Common.string2int32(ML_Common.GetDropDownValue(ddlAnalysisType, true));
                                objML_CokeDynamicResult.AnalysisType   = ML_Common.string2string(ML_Common.GetDropDownValue(ddlAnalysisType, false));

                                objML_CokeDynamicResult.FieldSize = ML_Common.clean(objML_CokeDynamicResult.FieldSize);


                                objML_CokeDynamicResult.FieldUnit = ML_Common.clean(objML_CokeDynamicResult.FieldUnit);
                                objML_CokeDynamicResult.FieldSpec = ML_Common.clean(objML_CokeDynamicResult.FieldSpec);
                                objML_CokeDynamicResult.MinValue  = ML_Common.clean(objML_CokeDynamicResult.MinValue);
                                objML_CokeDynamicResult.MaxValue  = ML_Common.clean(objML_CokeDynamicResult.MaxValue);


                                obhReturn = objBusinessClass.AddCokeDynamicResult(objML_CokeDynamicResult);
                            }
                        }
                        if (obhReturn == 1)
                        {
                            lblMsg.Visible = true;
                            lblMsg.Text    = "Record Saved Successfully";
                        }

                        FormFieldsClear();
                    }
                }

                catch (SqlException sqlExc)
                {
                    SqlException sqlExt = sqlExc;
                    return;
                }
                catch (Exception ex)
                {
                    Exception exc = ex;// Exception exc=ex;// LogManager.LogManager.WriteErrorLog(ex);
                }
            }



            //if (IsValid )
            //{
            //    //errNumber = -1;
            //    try
            //    {
            //        objBusinessClass = new BusinessLayer.BusinessClass();
            //        objML_CokeDynamicResult = new ML_CokeDynamicResult();
            //        string strAdminLoginName = string.Empty;
            //        if (Session["UserName"] != null)
            //        {
            //            strAdminLoginName = Session["UserName"].ToString();
            //        }



            //        objML_CokeDynamicResult.Id = ML_Common.string2Long(ML_Common.clean(txtId.Text));
            //        objML_CokeDynamicResult.CokeDynamicResultId = ML_Common.string2Long(ML_Common.clean(txtCokeDynamicResultId.Text));
            //        objML_CokeDynamicResult.CokeDynamicResult = ML_Common.clean(txtCokeDynamicResult.Text);
            //        objML_CokeDynamicResult.CokeDynamicId = ML_Common.string2int32(ML_Common.clean(txtCokeDynamicId.Text));
            //        objML_CokeDynamicResult.CokeDynamic = ML_Common.clean(txtCokeDynamic.Text);
            //        objML_CokeDynamicResult.CPCokeId = ML_Common.string2int32(ML_Common.clean(txtCPCokeId.Text));
            //        objML_CokeDynamicResult.CPCokeName = ML_Common.clean(txtCPCokeName.Text);
            //        objML_CokeDynamicResult.CokeTypeId = ML_Common.string2int32(ML_Common.clean(txtCokeTypeId.Text));
            //        objML_CokeDynamicResult.CokeType = ML_Common.clean(txtCokeType.Text);
            //        objML_CokeDynamicResult.CokeSupplierId = ML_Common.string2int32(ML_Common.clean(txtCokeSupplierId.Text));
            //        objML_CokeDynamicResult.CokeSupplier = ML_Common.clean(txtCokeSupplier.Text);
            //        objML_CokeDynamicResult.AnalysisTypeId = ML_Common.string2int32(ML_Common.clean(txtAnalysisTypeId.Text));
            //        objML_CokeDynamicResult.AnalysisType = ML_Common.clean(txtAnalysisType.Text);
            //        objML_CokeDynamicResult.FieldSize = ML_Common.clean(txtFieldSize.Text);
            //        objML_CokeDynamicResult.FieldUnit = ML_Common.clean(txtFieldUnit.Text);
            //        objML_CokeDynamicResult.FieldSpec = ML_Common.clean(txtFieldSpec.Text);
            //        objML_CokeDynamicResult.MinValue = ML_Common.clean(txtMinValue.Text);
            //        objML_CokeDynamicResult.MaxValue = ML_Common.clean(txtMaxValue.Text);


            //        // objML_CokeDynamicResult.IsActive = ML_Common.clean(ML_Common.bit2int(chkIsActive.Checked).ToString());
            //        // objML_CokeDynamicResult.IsArchive = ML_Common.clean(ML_Common.bit2int(chkIsArchive.Checked).ToString());
            //        // objML_CokeDynamicResult.CreatedDate = ML_Common.ToDateTimeSafe(System.DateTime.Now.ToString());
            //        // objML_CokeDynamicResult.CreatedBy = ML_Common.clean(string.Empty);
            //        // objML_CokeDynamicResult.ModifiedDate = ML_Common.ToDateTimeSafe(System.DateTime.Now.ToString());
            //        // objML_CokeDynamicResult.ModifiedBy = ML_Common.clean(string.Empty);

            //        int obhReturn = objBusinessClass.AddCokeDynamicResult(objML_CokeDynamicResult);

            //        if (obhReturn == 1)
            //        {
            //            lblMsg.Visible = true;
            //            lblMsg.Text = "Record Saved Successfully";
            //        }
            //        else if (obhReturn == 2)
            //        {
            //            lblMsg.Text = "Record Already Exists!";
            //            lblMsg.Visible = true;
            //        }
            //    }
            //    catch (SqlException sqlExc)
            //    {
            //        // LogManager.LogManager.WriteErrorLog(sqlExc);
            //        foreach (SqlError error in sqlExc.Errors)
            //        {
            //            errNumber = error.Number;
            //        }
            //        if (errNumber == 50000)
            //        {
            //        }
            //        return;
            //    }
            //    catch (Exception ex)
            //    {
            //        Exception exc = ex;// Exception exc=ex;// LogManager.LogManager.WriteErrorLog(ex);
            //    }
            //}
        }