private void grdArticleCategories_RowCommand(object sender, GridViewCommandEventArgs e) { int rowIndex = ((GridViewRow)((Control)e.CommandSource).NamingContainer).RowIndex; int categoryId = (int)this.grdArticleCategories.DataKeys[rowIndex].Value; int displaySequence = int.Parse((this.grdArticleCategories.Rows[rowIndex].FindControl("lblDisplaySequence") as Literal).Text); int replaceCategoryId = 0; int replaceDisplaySequence = 0; if (e.CommandName == "Fall") { if (rowIndex < (this.grdArticleCategories.Rows.Count - 1)) { replaceCategoryId = (int)this.grdArticleCategories.DataKeys[rowIndex + 1].Value; replaceDisplaySequence = int.Parse((this.grdArticleCategories.Rows[rowIndex + 1].FindControl("lblDisplaySequence") as Literal).Text); } } else if ((e.CommandName == "Rise") && (rowIndex > 0)) { replaceCategoryId = (int)this.grdArticleCategories.DataKeys[rowIndex - 1].Value; replaceDisplaySequence = int.Parse((this.grdArticleCategories.Rows[rowIndex - 1].FindControl("lblDisplaySequence") as Literal).Text); } if (replaceCategoryId > 0) { ArticleHelper.SwapArticleCategorySequence(categoryId, replaceCategoryId, displaySequence, replaceDisplaySequence); } if (e.CommandName == "Delete") { ArticleCategoryInfo articleCategory = ArticleHelper.GetArticleCategory(categoryId); if (ArticleHelper.DeleteArticleCategory(categoryId)) { ResourcesHelper.DeleteImage(articleCategory.IconUrl); } } base.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true); }
private void grdArticleCategories_RowDeleting(object sender, GridViewDeleteEventArgs e) { int categoryId = (int)grdArticleCategories.DataKeys[e.RowIndex].Value; ArticleCategoryInfo articleCategory = ArticleHelper.GetArticleCategory(categoryId); if (ArticleHelper.DeleteArticleCategory(categoryId)) { ResourcesHelper.DeleteImage(articleCategory.IconUrl); ShowMsg("成功删除了指定的文章分类", true); } else { ShowMsg("未知错误", false); } BindArticleCategory(); }