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 在需要在前台配置一页显示的条数

  • 相关阅读:
    纯CSS实现自动轮播,CSS变量的定义与使用,计算属性的使用
    input:file样式怎样修改
    Div转为Canvas简直不要太好玩~~~
    oracle nvl2函数
    oracle 子查询
    oracle 分组函数执行分析
    oracle外部表
    oracle USING 用法
    面向对象进阶
    面向对象基础
  • 原文地址:https://www.cnblogs.com/xinlang/p/1340945.html
Copyright © 2011-2022 走看看