protected void btnAdd_Click(object sender, ImageClickEventArgs e) { try { var obj = new DAL.Codes(); obj.CTID = int.Parse(ddlCodeTypes.SelectedValue.ToString()); obj.Code = CodeAdd.Text; obj.Description = DescriptionAdd.Text; if (obj.IsValid(BusinessRulesValidationMode.INSERT)) { obj.Insert(); LoadData(); ddlCodeTypes.SelectedValue = obj.CTID.ToString(); ShowDD(); var masterPage = (IControlRoomMaster)Master; masterPage.PageMessage = SRPResources.AddedOK; } 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); masterPage.PageError = message; } } catch (Exception ex) { var masterPage = (IControlRoomMaster)Master; masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message); } }