zoukankan      html  css  js  c++  java
  • 简单使用aspnetpage分页控件

        public partial class Default : System.Web.UI.Page
        {
            protected static string CONNECTIONSTRING = System.Configuration.ConfigurationManager.AppSettings["configer"];
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!this.Page.IsPostBack)
                {
                    AspNetPager1.RecordCount = 5;//一定要设计显示条数,不然就不能分页了。
                   GVBind();
                }
            }
            private void GVBind()
            {
                ForumDataContext db = new ForumDataContext();
                var q = from p in db.ForumPostInfos
                        select p;
                PagedDataSource pds = new PagedDataSource();
                pds.AllowPaging = true;
                pds.PageSize = AspNetPager1.PageSize;
                pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
                pds.DataSource = q.ToList();

                GridView1.DataSource = pds;
                GridView1.DataBind();
            }

           protected void AspNetPager1_PageChanged(object sender, EventArgs e)
            {
                GVBind();
            }

    注:AspNetPager1.PageSize 在需要在前台配置一页显示的条数

  • 相关阅读:
    清除浮动的方法
    网页滚动到顶部或底部加载
    任意两个数之间的随机数
    每五个一行
    js放大镜
    HTML5本地存储
    jquery checkbox radio 标签 选中的3种方法
    jquery mouseout mouseover 多次执行
    CentOS6.5安装MySQL5.7(也适合其他版本安装)
    ubuntu下ganglia3.7.2编译安装
  • 原文地址:https://www.cnblogs.com/xinlang/p/1340945.html
Copyright © 2011-2022 走看看