protected void Page_PreRender(object sender, EventArgs e) { if (grid.UpdatedRow != null) { var temp = MailFormatService.GetMailFormat(Convert.ToInt32(grid.UpdatedRow["ID"])); temp.FormatName = grid.UpdatedRow["FormatName"]; temp.Enable = Convert.ToBoolean(grid.UpdatedRow["Enable"]); temp.SortOrder = Convert.ToInt32(grid.UpdatedRow["SortOrder"]); temp.FormatType = (MailType)Convert.ToInt32(grid.UpdatedRow["FormatType"]); MailFormatService.UpdateMailFormat(temp); } DataTable data = _paging.PageItems; while (data.Rows.Count < 1 && _paging.CurrentPageIndex > 1) { _paging.CurrentPageIndex--; data = _paging.PageItems; } var clmn = new DataColumn("IsSelected", typeof(bool)) { DefaultValue = _inverseSelection }; data.Columns.Add(clmn); if ((_selectionFilter != null) && (_selectionFilter.Values != null)) { for (int i = 0; i <= data.Rows.Count - 1; i++) { int intIndex = i; if (Array.Exists(_selectionFilter.Values, c => c == (data.Rows[intIndex]["ID"]).ToString())) { data.Rows[i]["IsSelected"] = !_inverseSelection; } } } if (data.Rows.Count < 1) { goToPage.Visible = false; } grid.DataSource = data; grid.DataBind(); pageNumberer.PageCount = _paging.PageCount; lblFound.Text = _paging.TotalRowsCount.ToString(CultureInfo.InvariantCulture); }
protected void btnSave_Click(object sender, EventArgs e) { if (txtName.Text.Trim().Length == 0) { MsgErr(Resource.Admin_MailFormat_NoName); return; } if (CKEditorControl1.Text.Trim().Length == 0) { MsgErr(Resource.Admin_MailFormat_NoText); return; } int result = 0; if (!Int32.TryParse(txtSortOrder.Text, out result)) { MsgErr(Resource.Admin_MailFormat_SortNotNum); return; } MailFormat mailFormat = AddingNew ? new MailFormat() : MailFormatService.GetMailFormat(MailFormatId); mailFormat.FormatName = txtName.Text.Trim(); mailFormat.FormatText = CKEditorControl1.Text.Trim(); mailFormat.Enable = chkActive.Checked; mailFormat.SortOrder = Int32.Parse(txtSortOrder.Text); mailFormat.FormatType = (MailType)Int32.Parse(ddlTypes.SelectedValue); if (AddingNew) { MailFormatService.InsertMailFormat(mailFormat); Response.Redirect("MailFormat.aspx"); } else { lblMessage.Text = Resource.Admin_MailFormatDetail_Saved + "<br />"; lblMessage.Visible = true; MailFormatService.UpdateMailFormat(mailFormat); LoadMailFormat(); } }