if((this.DataGrid1.CurrentPageIndex==this.DataGrid1.PageCount-1)&&this.DataGrid1.Items.Count==1)
{
//如果当前页-1>1表示当前页为多页的最后一页
if(this.DataGrid1.CurrentPageIndex-1>1)
{
//由于是多页中的最后一页,且是最后一条记录,会产生异常,此时将当前页手动减1,避免异常
this.DataGrid1.CurrentPageIndex=this.DataGrid1.CurrentPageIndex-1;
}
else
{
this.DataGrid1.CurrentPageIndex=0;
}
}
//重新绑定数据
this.DataBind();
{
//如果当前页-1>1表示当前页为多页的最后一页
if(this.DataGrid1.CurrentPageIndex-1>1)
{
//由于是多页中的最后一页,且是最后一条记录,会产生异常,此时将当前页手动减1,避免异常
this.DataGrid1.CurrentPageIndex=this.DataGrid1.CurrentPageIndex-1;
}
else
{
this.DataGrid1.CurrentPageIndex=0;
}
}
//重新绑定数据
this.DataBind();