protected void ctlDelete_Click(object sender, ImageClickEventArgs e) { foreach (GridViewRow row in ctlRejectReasonGridView.Rows) { if ((row.RowType == DataControlRowType.DataRow) && (((CheckBox)row.FindControl("ctlSelect")).Checked)) { try { short id = UIHelper.ParseShort(ctlRejectReasonGridView.DataKeys[row.RowIndex]["ReasonID"].ToString()); DbScgReason reason = DbReasonService.FindByIdentity(id); DbReasonService.Delete(reason); } catch (Exception ex) { if (((System.Data.SqlClient.SqlException)(ex.GetBaseException())).Number == 547) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertInUseData", "alert('This data is now in use.');", true); } ctlRejectReasonGridView.DataCountAndBind(); } } } ReasonLangGridViewFinish(); ctlRejectReasonGridView.DataCountAndBind(); ctlUpdatePanelGridView.Update(); ctlRejectReasonGridView.DataBind(); }
protected void ctlReasonFormView_ItemUpdating(object sender, FormViewUpdateEventArgs e) { short reasonId = UIHelper.ParseShort(ctlReasonFormView.DataKey.Value.ToString()); DbScgReason reason = new DbScgReason(reasonId); GetReasonInfo(reason); try { DbReasonService.UpdateReason(reason); ctlRejectReasonGridView.DataCountAndBind(); ClosePopUp(); } catch (ServiceValidationException ex) { ValidationErrors.MergeErrors(ex.ValidationErrors); } }
protected void ctlReasonFormView_ItemInserting(object sender, FormViewInsertEventArgs e) { DbScgReason reason = new DbScgReason(); GetReasonInfo(reason); try { DbReasonService.AddReason(reason); ctlRejectReasonGridView.DataCountAndBind(); ctlReasonFormView.ChangeMode(FormViewMode.ReadOnly); ClosePopUp(); } catch (ServiceValidationException ex) { ValidationErrors.MergeErrors(ex.ValidationErrors); } }