protected void btnSave_Click(object sender, EventArgs e) { lblError.Text = string.Empty; lblError.Visible = false; lblSave.Text = string.Empty; lblSave.Visible = false; lblMessage.Visible = false; lblMessage.Text = string.Empty; try { using (TransactionScope scope = new TransactionScope()) { bool exists = InspectorManager.IsExist(txtName.Text.Trim(), Convert.ToInt32(hdId.Value)); if (exists) { lblMessage.Text = "Inspector Name already exists."; lblMessage.Visible = true; txtName.Focus(); return; } InspectorMaster inspector = InspectorManager.GetById(Convert.ToInt32(hdId.Value)); inspector.InspectorName = txtName.Text; inspector.Status = true; InspectorManager.Save(inspector); saveMsg = hdId.Value == "0" ? "Record Saved Sucessfully." : "Record Updated Sucessfully."; btnCancel_Click(null, null); lblSave.Text = saveMsg; lblSave.Visible = true; scope.Complete(); } //btnCancel_Click(null, null); //lblSave.Visible = true; //lblSave.Text = "Record Saved Sucessfully."; } catch (Exception ex) { lblError.Visible = true; lblError.Text = "Record Not Saved !!!"; } }