• 【转】AspNetPager分页控件用法


    AspNetPager分页控件解决了分页中的很多问题,直接采用该控件进行分页处理,会将繁琐的分页工作变得简单化,下面是我如何使用AspNetPager控件进行分页处理的详细代码:
    1.首先到www.webdiyer.com下载最新的AspNetPager.dll,直接在vs2005中添加引用即可。
    2.在页面上注册控件,引入该控件,当然,需要在页面中使用一个数据载体,我这里使用的是repeater控件。

    <%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

    <webdiyer:aspnetpager id="AspNetPager1" runat="server" CurrentPageButtonPosition="Center"
        Width="100%"  AlwaysShowFirstLastPageNumber="true" PagingButtonSpacing="10px" FirstPageText="首页"
            LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页" CustomInfoTextAlign="Center"  ShowNavigationToolTip="True" SubmitButtonText="跳" HorizontalAlign="Right" ButtonImageNameExtension="n" CpiButtonImageNameExtension="r"></webdiyer:aspnetpager>

    3.cs代码

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    namespace Pager
    {
        public partial class Demo_1 : System.Web.UI.Page
        {
            DAL.Books booksdal = new DAL.Books();
            int pagesize = 10;
            protected void Page_Load(object sender, EventArgs e)
            {
               
                if (this.IsPostBack)
                {
                }
                AspNetPager2.RecordCount = 1076;
                Band();
            }

            void Band()
            {
                this.Repeater1.DataSource = booksdal.GetTable(pagesize, AspNetPager2.StartRecordIndex,AspNetPager2.EndRecordIndex);
                this.Repeater1.DataBind();
         //public DataTable GetTable(int pagesize,int staindex,int endindex)
            //{
                
            //    string sql = " select top (@pagesize) * from (SELECT ROW_NUMBER() OVER (ORDER BY id) AS RowNumber,* FROM Books ) as A where A.RowNumber between @staindex and @endindex";
            //    SqlParameter[] pars = new SqlParameter[]
            //    {
            //        new SqlParameter("@pagesize",pagesize),
            //        new SqlParameter("@staindex",staindex),
            //        new SqlParameter("@endindex",endindex)
            //    };
               
            //    return DAL.SQL_Help.GetTable(sql, pars);
               
            //}
            }

            protected void AspNetPager1_PageChanged(object sender, EventArgs e)
            {
                Band();
            }
           
        }
    }
  • 相关阅读:
    报错:No module named 'ConfigParser'
    报错:AttributeError: module 'selenium.webdriver' has no attribute 'Chrome'
    报错:selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element:
    去掉“Chrome正在受到自动化测试软件的控制”
    XPath-Helper 的安装和使用
    Chrome您使用的是不受支持的命令行标记:--ignore-certificate-errors
    Message: unknown error: cannot get automation extension
    安装mysql-5.7.22-winx64中出现错误
    pip install 报错 Could not fetch URL
    Spring Boot 报错:Error creating bean with name 'entityManagerFactory' defined in class path resource
  • 原文地址:https://www.cnblogs.com/q975261413/p/4007523.html
Copyright © 2020-2023  润新知