AspNetPager分页控件说明

来源:互联网 发布:画线工具源码 编辑:程序博客网 时间:2024/06/06 20:53

使用方法:(AspNetPager.dll百度一下哦)

1、将AspNetPager.dll拷贝至站点文件夹下的Bin文件夹中,

如果站点中无Bin文件夹,可在站点中点击右键-添加ASP.NET文件夹


2、在VS2005工具箱中“常规”选项卡中点右键选择“选择项…”

点击“浏览…”,找到站点中的AspNetPager.dll后确定,工具箱中常规中出现了它

4、使用分页功能时,将AspNetPager分页控件拖曳至相应页面,编码即可。

 
5、页面.aspx里添加代码:

 <!--分页控件--->

    <webdiyer:AspNetPager ID="AspNetPager1" runat="server" AlwaysShow="True"

               CustomInfoHTML="共%PageCount%页,当前为第%CurrentPageIndex%页"

                FirstPageText="首页" LastPageText="尾页" LayoutType="Table" NextPageText="后页"

                OnPageChanging="AspNetPager1_PageChanging" PageSize="5"

                  PagingButtonLayoutType="Span" PrevPageText="前页"

                 ShowBoxThreshold="2" ShowCustomInfoSection="Right"

                 ShowNavigationToolTip="True" SubmitButtonText="Go" TextAfterPageIndexBox="页"

                 TextBeforePageIndexBox="转到" Width="757px">

    </webdiyer:AspNetPager>

 

6、//页面处理类代码:

public partial class Ship : System.Web.UI.Page

   protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            this.AspNetPager1.RecordCount = UserManage.getPageCount();

            databind();

        }
    }

    public void databind()
    {

        int pagesize = this.AspNetPager1.PageSize;

        int pageindex = (this.AspNetPager1.CurrentPageIndex - 1) * this.AspNetPager1.PageSize;

        DataSet ds = UserManage.getPage(pagesize, pageindex);

 //空间绑定数据

        this.RepeaterSR.DataSource = ds.Tables[0];

        this.RepeaterSR.DataBind();

    }

    protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
    {

        this.AspNetPager1.CurrentPageIndex = e.NewPageIndex;

        databind();

    }
}

7、//辅助类代码:
class UserManage
{   
 
    public static DataSet getPage(int pagesize, int pageindex)
    {

 //调用Sqlhelper

        SqlHelper sq = new SqlHelper();

        string strsql = "select top " + pagesize + " * from 表 where 主键 not in (select top " + pageindex + " Si_Id from 表) order by 主键";

       
        DataSet ds =sq.ExecuteDataset(System.Data.CommandType.Text,strsql,null);

        return ds;

    }

    /// <summary>

    /// 分页总数

    /// </summary>

    /// <param name="tablename"></param>

    /// <returns></returns>

    public static int getPageCount()
    {
 //调用Sqlhelper

        SqlHelper sp = new SqlHelper();

        string strsql = "select count(Si_Id) from t_ShipInfo ";

        int count = Convert.ToInt32(sp.ExecuteScalar(System.Data.CommandType.Text,strsql,null));

        return count;

    }

}

原创粉丝点击