Asp.net Mvc Dwz 分页

下面的代码还是有些问题的,随后再解决吧

 @{
        var pagination = ViewBag.pagination as DwzMvc.DwzPagination;
    }
    <div class="panelBar">
        <div class="pages">
            <span>显示</span>
            <select class="combox" name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
 
                @foreach (var i in new[] { 20, 50, 100, 200 })
                {
                    <option @(i == pagination.NumperPage ? "selected=\"selected\"" : "") value="@i">@i</option>
                }
 
            </select>
            <span>条,共@(pagination.TotalCount)条</span>
        </div>
 
        <div class="pagination" targettype="@pagination.TargetType" totalcount="@pagination.TotalCount" numperpage="@pagination.NumperPage" pagenumshown="@pagination.PagenumShown" currentpage="@pagination.CurrentPage"></div>
 
    </div>
    <form id="pagerForm" method="post" action="@Url.HttpRouteUrl(pagination.RouteName, pagination.RouteValues)">
 
        <input type="hidden" name="pageNum" value="1" />
        <input type="hidden" name="numPerPage" value="@pagination.NumperPage" />
 
        @foreach (var key in pagination.NameValues.AllKeys)
        {
            <input type="hidden" name="@key" value="@pagination.NameValues[key]" />
        }
    </form>

 

 

 
    public class Constant
    {
        public const string navTab = "navTab";
 
    }
 
    /// <summary>
    /// DWZ的分页模型
    /// </summary>
    public class DwzPagination
    {
 
        private int pagenumshown = 10;
        private int totalcount;
        private int numperpage = 20;
        private int currentpage = 1;
 
        private NameValueCollection _nameValues = new NameValueCollection();
        private string _targetType = Constant.navTab;
        private string _routeName;
        private RouteValueDictionary _routeValues;
 
        /// <summary>
        /// 显示多少个页码
        /// </summary>
        public int PagenumShown
        {
            get { return pagenumshown; }
            set { pagenumshown = value; }
        }
        /// <summary>
        /// 总量
        /// </summary>
        public int TotalCount
        {
            get { return totalcount; }
            set { totalcount = value; }
        }
        /// <summary>
        /// 每页多少条
        /// </summary>
        public int NumperPage
        {
            get
            {
                var quest = Dev.Comm.Web.DevRequest.GetInt("numPerPage", 0);
                if (quest > 0)
                {
                    numperpage = quest;
                }
                return numperpage;
            }
            private set
            {
 
                numperpage = value;
            }
        }
        /// <summary>
        /// 当前页码
        /// </summary>
        public int CurrentPage
        {
            get { return currentpage; }
            set { currentpage = value; }
        }
        /// <summary>
        /// 保存相关的值
        /// </summary>
        public NameValueCollection NameValues
        {
            get { return _nameValues; }
            set { _nameValues = value; }
        }
        /// <summary>
        /// 打开类型
        /// </summary>
        public string TargetType
        {
            get { return _targetType; }
            set { _targetType = value; }
        }
 
        public string RouteName
        {
            get { return _routeName; }
            set { _routeName = value; }
        }
 
        public System.Web.Routing.RouteValueDictionary RouteValues
        {
            get { return _routeValues; }
            set { _routeValues = value; }
        }
    }

你可能感兴趣的:(asp.net)