protected void lnkDelete_Click(object sender, EventArgs e) { try { LinkButton lnkUpdate = (LinkButton)sender; objAttachmentcls = new AttachmentCls(); objAttachmentcls.DocumentId = lnkUpdate.CommandArgument; int res = objAttachmentcls.DeleteAttachment(); if (res > 0) { // File.Delete(Path); HttpContext.Current.Cache.Remove("ATHData"); BindData(); ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Deleted Successfully');", true); } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Not Deleted');", true); } } catch (System.Exception ex) { // ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('DBID used somewhere');", true); } }