protected void btnCTDelete_Click(object sender, ImageClickEventArgs e) { var key = int.Parse(CTID.Text); try { var obj = new CodeType(); if (obj.IsValid(BusinessRulesValidationMode.DELETE)) { CodeType.FetchObject(key).Delete(); ddlCodeTypes.SelectedValue = "0"; LoadData(); ddlCodeTypes_SelectedIndexChanged(null, null); var masterPage = (IControlRoomMaster)Master; if (masterPage != null) { masterPage.PageMessage = SRPResources.DeleteOK; } } else { var masterPage = (IControlRoomMaster)Master; string message = String.Format(SRPResources.ApplicationError1, "<ul>"); foreach (BusinessRulesValidationMessage m in obj.ErrorCodes) { message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage); } message = string.Format("{0}</ul>", message); if (masterPage != null) { masterPage.PageError = message; } } } catch (Exception ex) { var masterPage = (IControlRoomMaster)Master; if (masterPage != null) { masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message); } } }