protected void lbtnDelete_Click(object sender, EventArgs e) { string code = ((LinkButton)sender).CommandArgument; try { string imageUrl = TheItemMgr.LoadItem(code).ImageUrl; if (File.Exists(Server.MapPath(imageUrl))) { File.Delete(Server.MapPath(imageUrl)); } TheItemMgr.DeleteItem(code); ShowSuccessMessage("MasterData.Item.DeleteItem.Successfully", code); UpdateView(); } catch (Castle.Facilities.NHibernateIntegration.DataException ex) { ShowErrorMessage("MasterData.Item.DeleteItem.Fail", code); } }