欢迎访问:常州市武进区嘉泽中心小学网站 !今天是:
栏目列表
您现在的位置是:首页>>教师>>计算机技术>>网站制作技术>>文章内容
asp.net关于分页上的数据删除问题
发布时间:2008-11-20   点击:   来源:本站原创   录入者:佚名
 

当在最后一页删除数据的时候,情形是删除了最后一页的所有数据,那么会出现

Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount

 

原因是CurrentPageIndex==PageCount!

这里的提示是CurrentPageIndex must be >=0  and PageCount<PageCount.

 

所以解决方法就是改一下当前 CurrentPageIndex 的值,把它设置为0(第一页)或任何小于PageCount的值.

我尝试了以下的方法解决没有成功:

//DataGrid1.PageCount=1;  这里PageCount是不可以更改的!!!

 

//DataGrid1.CurrentPageIndex-=1;  先-1

/*if(DataGrid1.PageCount-DataGrid1.CurrentPageIndex>1)

 {   DataGrid1.CurrentPageIndex+=1;             }*/

如果判断他们符合条件再+1,因为CurrentPageIndex必须小于PageCount, 所以要先-1,但是此方法不能实现,可能是执行完删除这个动作马上就会检查CurrentPageIndex的值和PageCount的值,如果不符合条件就会抛出异常,不会给下面的语句以执行的机会!


附件:
    关闭窗口
    打印文档
    账号登录
    保持登录 忘记密码?
    账号与武进教师培训平台同步