Asp.NETPersonnalBlogSystem/Admin/ArticleList.aspx.cs

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI.WebControls;
using Asp.NETPersonnalBlogSystem.BLL;
using Asp.NETPersonnalBlogSystem.Models;

namespace Asp.NETPersonnalBlogSystem.Admin
{
    /// <summary>
    /// 文章列表管理页面
    /// 提供文章的查看、搜索、删除等功能
    /// </summary>
    public partial class ArticleList : System.Web.UI.Page
    {
        private int pageIndex = 1;
        private int pageSize = 10;
        private ArticleService articleService = new ArticleService();
        private CategoryService categoryService = new CategoryService();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadCategories();
                LoadArticles();
            }
        }

        /// <summary>
        /// 加载分类下拉列表
        /// </summary>
        private void LoadCategories()
        {
            var categories = categoryService.GetAllCategories();
            foreach (var category in categories)
            {
                ddlCategory.Items.Add(new ListItem(category.CategoryName, category.CategoryId.ToString()));
            }
        }

        /// <summary>
        /// 加载文章列表
        /// </summary>
        private void LoadArticles()
        {
            int categoryId = Convert.ToInt32(ddlCategory.SelectedValue);
            int status = Convert.ToInt32(ddlStatus.SelectedValue);
            string keyword = txtKeyword.Text.Trim();

            if (!int.TryParse(Request.QueryString["page"], out pageIndex))
            {
                pageIndex = 1;
            }

            List<Article> articles = articleService.GetArticleList(pageIndex, pageSize, categoryId, keyword, status);
            int totalCount = articleService.GetArticleCount(categoryId, keyword, status);
            int totalPages = (int)Math.Ceiling((double)totalCount / pageSize);

            gvArticles.DataSource = articles;
后面还有 89 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。