各位大虾能否教新人做这个例子。要求:用存储过程分页。使用DataList。存储过程,也是从这里找到的:CREATE procedure main_table_pwqzc
(@pagesize int,
@pageindex int,
@docount bit,
@this_id int)
as
if(@docount=1)
begin
select count(id) from luntan where this_id=@this_id
end
else
begin
declare @PageLowerBound int
declare @PageUpperBound int
set @PageLowerBound=(@pageindex-1)*@pagesize
set @PageUpperBound=@PageLowerBound+@pagesize
create table #pageindex(id int identity(1,1) not null,nid int)
set rowcount @PageUpperBound
insert into #pageindex(nid)
select id from luntan where this_id=@this_id order by reply_time desc
select O.*
from luntan O,#pageindex p
where O.id=p.nid and p.id>@PageLowerBound and p.id<=@PageUpperBound order by p.id
end
GO然后c#的代码如何写啊?

解决方案 »

  1.   

    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
                CurrentPage = Convertor.ToInt32( Request["Page"]);
                if( CurrentPage <= 0 )
                    CurrentPage = 1;            if( !this.IsPostBack )
                {
                    CheckLogin();
                    if( user.Usertype != UserType.Mfr )
                        PleaseLogin();                Int32 RecordCount = StandbyDB.Count( user.UserID );//获取总数
                    this.lblRecordCount.Text = RecordCount.ToString();
                    dlStandbyBind();
                }
    }
    private void dlStandbyBind()
            {
                //备用的产品的效率可以优化一下
                Int32 PageSize=4, PageCount=0, RecordCount=0;            RecordCount = Int32.Parse(lblRecordCount.Text);           
                PageCount = RecordCount % PageSize == 0 ? RecordCount / PageSize : RecordCount / PageSize + 1;            SqlDataReader dr = null;
                dr = StandbyDB.GetByPage( PageSize, CurrentPage, user.UserID );
                dlStandby.DataSource = dr;
                dlStandby.DataBind();
                if( dr != null )
                    dr.Close();
                dr = null;
                
                if( PageCount <= 0 )
                    PageCount = 1;
                if( CurrentPage >= PageCount )
                    CurrentPage = PageCount;            lblPageCount.Text = PageCount.ToString();
                lblCurrentPage.Text = CurrentPage.ToString();
                lblRecordCount.Text = RecordCount.ToString();
                
                this.LinkButtonNext.NavigateUrl = "MyProducts.aspx?Page=" + (CurrentPage + 1);
                this.LinkButtonNext.Enabled = (CurrentPage < PageCount);
                this.LinkButtonPrev.NavigateUrl = "MyProducts.aspx?Page=" + (CurrentPage - 1);
                this.LinkButtonPrev.Enabled = (CurrentPage > 1);
            }参考一下吧
      

  2.   

    下载webdiyer做的控件就有了嘛...好几种