MVC分頁技術

來源:互聯網
上載者:User

標籤:

這個是用的外掛程式分頁技術

前台引用和js

    <script type="text/javascript" src="/js/jquery-1.10.2.min.js"></script>    <script type="text/javascript" src="/js/kkpager.min.js"></script>    <link rel="stylesheet" type="text/css" href="/css/kkpager_orange.css" />  function getParameter(name) {            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");            var r = window.location.search.substr(1).match(reg);            if (r != null) return unescape(r[2]); return null;        }        $(function () {var pageCount = $(‘#pageCount‘).val();//擷取總頁碼            var totalRecords = $(‘#totalRecords‘).val();//擷取總條數            var pageNo = getParameter(‘pno‘);            if (!pageNo) {                pageNo = 1;            }            //產生分頁            //有些參數是可選的,比如lang,若不傳有預設值            kkpager.generPageHtml({                //當前頁碼                pno: pageNo,                //總頁碼                total: pageCount,                //總資料條數                totalRecords: totalRecords,                //連結前部                hrefFormer: ‘/ProductQuality/ExpertProduct‘,                //連結尾部                hrefLatter: ‘‘,                getLink: function (n) {                    return this.hrefFormer+this.hrefLatter+‘?id=‘[email protected](Convert.ToInt32(INDID))+‘&pno=‘ + n;                }            });});




//Html代碼
 <div style="width:800px;margin:0 auto;">
                    <div id="kkpager"></div>
                </div>

mvc中

        public ActionResult ExpertProduct(string id,string pno)        {            int pageIndex;            int pageSize=2;            if (!int.TryParse(pno,out pageIndex))            {                pageIndex = 1;            }            id = id == null ? "0101" : id;//擷取專家            Dictionary<string, object> param = new Dictionary<string, object>();            param.Add("ID", id);            string inspectionUser = RouteManager.GetApiRoute("ProductQuality", "GetInspectionExpert", param); ;            IList<InspectionUsers> model = JsonConvert.DeserializeObject<List<InspectionUsers>>(Catalogs.GetCatalogs(inspectionUser));this.ViewBag.pageCount = Math.Ceiling((double)model.Count/pageSize);//擷取總頁碼
this.ViewBag.totalRecords = model.Count;//總條數
return View(model.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList()); }

 

 

 

http://files.cnblogs.com/files/xbblogs/uploadify.zip

MVC分頁技術

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.