ASP.NET中分页AspNetPager的解释

本文介绍AspNetPager组件的使用方法及参数设置,通过实例演示如何实现数据分页显示,并附带提供了一个存储过程来配合AspNetPager组件进行数据检索。

     AspNetPager组件

 

     一、用到的组件参数

RecordCount 总记录数

StartRecordIndex 开始记录编号(用于存储过程中)

EndRecordIndex结束记录编号(用于存储过程中)

二.使用方法

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Admin_User"] == null)
        {
            Response.Redirect("login.aspx");
            Response.End();
        }
        else
        {
            NewsSystem newsSystem = new NewsSystem();
            AspNetPager1.RecordCount = newsSystem.Get_NewsNum();
        }
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        BinData();
    }
    public void BinData()
    {
        NewsSystem newsSystem = new NewsSystem();
        News_List.DataSource = newsSystem.Get_News(AspNetPager1.StartRecordIndex, AspNetPager1.EndRecordIndex);
        News_List.DataBind();
    }

 

 

附上存储过程:

 

ALTER procedure fy

(@startIndex int,

@endIndex int,

@docount int)

as

set nocount on

if(@docount=1)

select count(*) from Xt_Article

else

begin

declare @indextable table(id int identity(1,1),nid int)

set rowcount @endIndex

insert into @indextable(nid) select id from Xt_Article order by id asc

select * from Xt_Article O,@indextable t where O.id=t.nid

and t.id between @startIndex and @endIndex order by t.id

end

set nocount off

 

转载于:https://www.cnblogs.com/jason_yjau/archive/2008/07/24/1250915.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值