当前位置:编程学习 > C#/ASP.NET >>

.net 分页

求一个类似京东的分页。 .NET 分页 --------------------编程问答-------------------- 这里看一下:http://www.webdiyer.com/ --------------------编程问答-------------------- 你就从了一楼吧! --------------------编程问答-------------------- 了解分页思路,根据实际情况,自己写一个就行
都靠控件 = 不靠谱 --------------------编程问答-------------------- ASPNETPAGER --------------------编程问答-------------------- 一楼的好用 --------------------编程问答-------------------- 炒个样式不久行了,,, --------------------编程问答--------------------
引用 3 楼 wansai00 的回复:
了解分页思路,根据实际情况,自己写一个就行
都靠控件 = 不靠谱

同意 --------------------编程问答-------------------- 还是自己写一个吧!或者就用最简单的! --------------------编程问答--------------------

DAL.中间库存 bll = new DAL.中间库存();
            string strwhere = "分类ID = 3";
            int count = bll.GetRecordCount(strwhere);
            if (count == 0)
            {
                pagelist = "<div class=\"fenye\">暂无数据</div>";
                return;
            }
            int pagesize = 20;
            int yushu = count % pagesize;
            int yeshu = count / pagesize;
            int capacity = 0;
            if (yushu > 0)
            {
                yeshu += 1;
            }
            if (page > yeshu)
            {
                pagelist = "<div class=\"fenye\">暂无数据</div>";
                return;
            }
            if (page < yeshu)
            {
                capacity = pagesize;
            }
            if (page == yeshu)
            {
                if (yushu == 0)
                {
                    capacity = pagesize;
                }
                else
                {
                    capacity = yushu;
                }
            }
            string url = Utils.CombUrlTxt("123.aspx", "page={0}", "_new_id");
            pagelist = ShowPage(yeshu, page, url, count);
            li = bll.分页(pagesize, page, capacity, strwhere);
--------------------编程问答--------------------

#region 分页
        /// <summary>
        /// 分页
        /// </summary>
        public Model.中间库存[] 分页(int pagesize, int currentindex, int capacity, string strwhere)
        {
            string sql = string.Empty;
            if (currentindex == 1)
            {
                sql = "select top " + capacity + " ID,名称,数量 from 中间库存 where " + strwhere + " order by ID asc";
            }
            else
            {
                sql = "select top " + capacity + " ID,名称,数量 from 中间库存 where " + strwhere + " and ID > (select max(ID) from (select top " + (currentindex - 1) * pagesize + " ID from 中间库存 where " + strwhere + " order by ID asc) as t) order by ID asc";
            }
            SqlDataReader dr = DbHelperSQL.ExecuteReader(sql);
            Model.中间库存 model = null;
            Model.中间库存[] list = new Model.中间库存[capacity];
            int i = 0;
            while (dr.Read())
            {
                model = new Model.中间库存
                {
                    ID = dr.GetInt32(0),
                    名称 = dr.GetString(1),
                    数量 = dr.GetInt32(2)
                };
                list[i] = model;
                i++;
            }
            dr.Close();
            model = null;
            return list;
        }
        #endregion
--------------------编程问答--------------------
引用 2 楼 fangxuan 的回复:
你就从了一楼吧!


引用 5 楼 tan598121925 的回复:
一楼的好用


你就从了一楼了 --------------------编程问答-------------------- ajax配合js函数


#region 三参数分页链接
        /// <summary>
        /// 三参数分页链接
        /// </summary>
        private static string 三参数分页链接(int yeshu, int count, int currentpage, int flag, string fun, string px)
        {
            if (yeshu <= 1)
            {
                return "";
            }
            StringBuilder sb = new StringBuilder();
            string first = string.Empty;
            string up = string.Empty;
            string down = string.Empty;
            string last = string.Empty;
            if (currentpage == 1)
            {
                first = "<a disabled='disabled'>首页</a>";
                up = "<a disabled='disabled'>上一页</a>";
            }
            if (currentpage > 1)
            {
                first = "<a href='javascript:void(0)' onclick='" + fun + "(1," + flag + "," + px + ")'>首页</a>";
                up = "<a href='javascript:void(0)' onclick='" + fun + "(" + (currentpage - 1) + "," + flag + "," + px + ")'>上一页</a>";
            }
            sb.Append(first + up);
            for (int i = currentpage - 8; i <= currentpage; i++)
            {
                if (i <= 0)
                {
                    continue;
                }
                if (i == currentpage)
                {
                    sb.Append("<a class='current'>" + i + "</a>");
                }
                else
                {
                    sb.Append("<a href='javascript:void(0)' onclick='" + fun + "(" + i + "," + flag + "," + px + ")'>" + i + "</a>");
                }
            }
            for (int i = currentpage + 1; i <= currentpage + 9; i++)
            {
                if (i > yeshu)
                {
                    break;
                }
                sb.Append("<a href='javascript:void(0)' onclick='" + fun + "(" + i + "," + flag + "," + px + ")'>" + i + "</a>");
            }
            if (currentpage < yeshu)
            {
                down = "<a href='javascript:void(0)' onclick='" + fun + "(" + (currentpage + 1) + "," + flag + "," + px + ")'>下一页</a>";
                last = "<a href='javascript:void(0)' onclick='" + fun + "(" + yeshu + "," + flag + "," + px + ")'>尾页</a>";
            }
            if (currentpage == yeshu)
            {
                down = "<a disabled='disabled'>下一页</a>";
                last = "<a disabled='disabled'>尾页</a>";
            }
            sb.Append(down + last);
            sb.Append("   共" + yeshu + "页  " + count + "条");
            return sb.ToString();
        }
        #endregion
--------------------编程问答-------------------- 请指教  --------------------编程问答-------------------- ajax+存储过程分页就可以了。 --------------------编程问答--------------------
引用 1 楼 webdiyer 的回复:
这里看一下:http://www.webdiyer.com/

你这个怎么用呀,有个小例子吗 --------------------编程问答--------------------
引用 15 楼 mh_ma 的回复:
Quote: 引用 1 楼 webdiyer 的回复:

这里看一下:http://www.webdiyer.com/

你这个怎么用呀,有个小例子吗

示例和文档都有啊 --------------------编程问答-------------------- 一楼的一直都用着!!非常好用 --------------------编程问答-------------------- gridveiew可以分页
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,