コード例 #1
0
        public ActionResult Category(long cateId, int page = 1, int pageSize = 1)
        {
            var category = new CatetoryDao().viewDetail(cateId);

            ViewBag.Category = category;
            int totalRecord = 0;
            var model       = new ProductDao().ListbyCatetoryId(cateId, ref totalRecord, page, pageSize);

            ViewBag.Total = totalRecord;
            ViewBag.Page  = page;

            int maxPage   = 5;
            int totalPage = 0;

            totalPage         = (int)Math.Ceiling((double)(totalRecord / pageSize));
            ViewBag.TotalPage = totalPage;
            ViewBag.MaxPage   = maxPage;
            ViewBag.First     = 1;
            ViewBag.Last      = totalPage;
            ViewBag.Next      = page + 1;
            ViewBag.Prev      = page - 1;


            return(View(model));
        }
コード例 #2
0
        public void SetViewBag(long?selectedId = null)
        {
            var dao = new CatetoryDao();

            ViewBag.CatetoryID = new SelectList(dao.ListAll(), "ID", "Name", selectedId);
        }