BindGridView 的分页
//----------------------------------------aspx-------------------------------------------------
public void BindGridView(int curPage)
{
//分页要显示 一页显示几行,当前页数,按什么排序
this.GridViewInfo.DataSource = this.newsmanager.GetPageNews(2, curPage, "");
this.GridViewInfo.DataBind();
int count = this.newsmanager.GetPageCount();
this.AspNetPager1.RecordCount = count;
this.AspNetPager1.PageSize = 2;
}
//这点是分页空件的事件………………
protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
this.BindGridView(e.NewPageIndex);// ***
}
//----------------------------------------SQL-------------------------------------------------
--- 在SQL2000上可能回有错
-- 创建分页存储过程
create PROCEDURE dbo.UP_News_Page
(
@pageSize int,-- 一页显示几条
@curPage int,-- 第几页
@orderName nvarchar(250)
)
as
set nocount on
declare @sql nvarchar(max) --声明一个拼接字符串
set @sql = 'select top ' + convert(nvarchar(250),@pageSize) + ' * from News'
set @sql = @sql + ' where NewsId not in(select top ' + convert(nvarchar(250),(@curPage-1)*@pageSize)
set @sql = @sql + ' NewsId from News ) '
print @sql
exec(@sql)
set nocount off
go
-- 创建 得到全部的总数 的存储过程
create proc dbo.UP_News_Page_Count
as
set nocount on
--- 得到全部
select count(NewsId) from News
set nocount off
go
浙公网安备 33010602011771号