在WebForm上放一个Button控件和一个DataGrid控件,如何实现点击一下Button,DataGrid中就显示下一页的数据?(在vs.net2003环境中)

解决方案 »

  1.   

    你点一下就设置DAtaGrid的当前页为下一页就可以了
      

  2.   

    那要看你是用DataGrid自带的分页还是自己写的分页。
    如果是自带的分页,把DataGrid的PageIndex加1就可以了。
    自己写的也是同样道理。
      

  3.   

    很多方法哦,最简单的用DATAGRID自带的分页
      

  4.   

    关键是我不知道如何获得当前页第一行和最后一行记录的序号.比如用:DataGrid1.AllowPaging=true;
    DataGrid1.AllowCustomPaging=true;
    DataGrid1.PageSize=8;if(DataGrid1.CurrentPageIndex>0 && DataGrid1.CurrentPageIndex<DataGrid1.PageCount){
      DataGrid1.CurrentPageIndex+=1;
      }string selectSql="select  * from Student where int_id between "+(DataGrid1.CurrentPageIndex)*DataGrid1.PageSize+1+" and "+(DataGrid1.CurrentPageIndex+1)*DataGrid1.PageSize;  -------→①//string selectSql="select  * from Student where int_id between 9 and 16"; ------→②
    SqlDataAdapter da=new SqlDataAdapter(selectSql,connStr);DataSet ds=new DataSet();da.Fill(ds,"student");DataGrid1.DataSource=ds;
    DataGrid1.DataBind();
    ds.Clear();
    使用①句的话,只显示第一页的记录;使用②句倒可以显示9到16行的记录。我怎样才能做到点击一下按钮,就8行8行的向下显示呢,即第一页显示1-8行的记录,第二页显示9-16行的记录,依次类推。
      

  5.   

    邦定当前table的视图,只需要:DataGrid1 .CurrentPageIndex =DataGrid1 .CurrentPageIndex =1;
    就可以了
    不要忘了重新邦定:DataView  dv=(DataView )CreateTable();
    DataGrid1 .DataSource =dv;
    DataGrid1 .DataBind ();