其他分享
首页 > 其他分享> > mvc.net分页查询案例——控制器(HomeController.cs)

mvc.net分页查询案例——控制器(HomeController.cs)

作者:互联网

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using HouseSys.Models;
using HouseSys.BLL;

namespace HouseSys.Controllers.Home
{
    public class HomeController : Controller
    {
        StreetBLL streetBll = new StreetBLL();
        HouseTypeBLL typeBll = new HouseTypeBLL();
        HouseBLL houseBll = new HouseBLL();
       
        /// <summary>
        /// 进入首页
        /// 获取所有的房屋位置
        /// 获取所有的房型
        /// </summary>
        /// <returns></returns>
        public ActionResult Index(int pageIndex = 1,int pageSize = 5)
        {
            List<StreetModel> streetList = streetBll.GetStreets();
            List<HouseTypeModel> typeList = typeBll.GetHouseTypes();
            SelectList selectStree = new SelectList(streetList,"Id","Name");
            SelectList selectType = new SelectList(typeList, "Id", "Name");
            int AllCount = 0;
            List<HouseModel> houseList = houseBll.GetHousesAll(pageIndex,pageSize,out AllCount);
            ViewData["selectStree"] = selectStree;
            ViewData["selectType"] = selectType;
            PagedList<HouseModel> pageList = new PagedList<HouseModel>(houseList,pageIndex,pageSize,AllCount);

            return View(pageList);
        }

    }
}

标签:pageSize,SelectList,HomeController,System,mvc,new,cs,using,selectType
来源: https://blog.51cto.com/u_12718584/2843740