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

来源:互联网 发布:php抽象类和接口的区别 编辑:程序博客网 时间:2024/06/05 10:21
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);        }    }}

阅读全文
0 0
原创粉丝点击