private void updatecode() { try { if (hd.Value != "true") { lblcheckDoubleError.Text = String.Empty; GridViewRow row = GridView1.SelectedRow; int tax_id = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value); decimal TaxPercent = decimal.Parse(txtTaxPercent.Text); context.sp_UpdateTax(companyId, branchId, tax_id, txtTaxName.Text, TaxPercent, User_id, DateTime.Today); btnUpdate.Visible = false; btnSave.Visible = true; clr(); loadDataTable(); divalert.Visible = true; lblAlert.Text = "Tax Updated Successfully "; } else { divalert.Visible = false; lblcheckDoubleError.ForeColor = System.Drawing.Color.Red; lblcheckDoubleError.Text = "This Tax name already Exists"; } } catch (Exception ex) { ErrorLog.saveerror(ex); //Do Logging } }