protected void btnDelete_Click(object sender, EventArgs e) { int emailogoID = int.Parse(this.hdnSelectedId.Value); // int distributorId = int.Parse(this.ddlDistributor.SelectedValue); if (emailogoID > 0) { using (TransactionScope ts = new TransactionScope()) { try { EmailLogoBO objEmailLogo = new EmailLogoBO(this.ObjContext); objEmailLogo.ID = emailogoID; objEmailLogo.GetObject(); string labelPath = objEmailLogo.EmailLogoPath; objEmailLogo.Delete(); this.ObjContext.SaveChanges(); ts.Complete(); string fileLocation = IndicoConfiguration.AppConfiguration.PathToDataFolder + "\\EmailLogos\\" + labelPath; if (File.Exists(fileLocation)) { try { File.Delete(fileLocation); } catch { } } } catch (Exception ex) { IndicoLogging.log.Error("Error occured while deleting the label", ex); } this.cvLabel.Enabled = false; // this.rfvLabelName.Enabled = false; } } this.PopulateEmailLogo(); }