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

  • 相关阅读:
    飞入飞出效果
    【JSOI 2008】星球大战 Starwar
    POJ 1094 Sorting It All Out
    POJ 2728 Desert King
    【ZJOI 2008】树的统计 Count
    【SCOI 2009】生日快乐
    POJ 3580 SuperMemo
    POJ 1639 Picnic Planning
    POJ 2976 Dropping Tests
    SPOJ QTREE
  • 原文地址:https://www.cnblogs.com/xinlang/p/1340945.html
Copyright © 2011-2022 走看看