sql2000加repeater(asp.net(C#))做分页

来源:百度知道 编辑:UC知道 时间:2024/06/19 10:23:39
sql2000 中top后不能跟变量,而且又用repeater做分页。我要怎么能实现“最后一页”这个功能呢?我要具体操作代码,采纳后还会追加分的。谢谢各位大虾了,帮帮忙!!!

declare @sql varchar(1000)
set @sql='select top '+cast(@toprows as varchar) + ' from users '
exec(@sql)

组合字符串

private void BinderList(string sql)
{
//创建分页
SqlDataAdapter da = new SqlDataAdapter(sql, ConfigCon.InfoDbConnStr);
DataSet ds = new DataSet();
da.Fill(ds, "type");
PagedDataSource objpage = new PagedDataSource();
objpage.DataSource = ds.Tables["type"].DefaultView;
//设置总的查询结果
Label1.Text = ds.Tables["type"].Rows.Count.ToString();
//允许分页,每页行数据
objpage.AllowPaging = true;
objpage.PageSize =8;
//总页数
Label3.Text = objpage.PageCount.ToString();

//定义变量保存当前页
int curpage = 0;
//判断是否具有跳转的请求
if (Request.QueryString["page"] != null)
{
curpage =