判断一下DataGrid:
if((System.Convert.ToInt32(this.LabRecordCount.Text.Trim())-CheckCount)%10 == 0 && this.DGridEXAM_QUESTION.CurrentPageIndex != 0)
{
this.DGridEXAM_QUESTION.CurrentPageIndex = this.DGridEXAM_QUESTION.CurrentPageIndex-1;
}
意思就是,如果删除了最后一页的所有记录,则DataGrid的当前页必须减1,就不会报错了.
if((System.Convert.ToInt32(this.LabRecordCount.Text.Trim())-CheckCount)%10 == 0 && this.DGridEXAM_QUESTION.CurrentPageIndex != 0)
{
this.DGridEXAM_QUESTION.CurrentPageIndex = this.DGridEXAM_QUESTION.CurrentPageIndex-1;
}
意思就是,如果删除了最后一页的所有记录,则DataGrid的当前页必须减1,就不会报错了.
解决方案 »
- button和click事件和OnClick事件冲突 - -。
- XZFileService和Bitmap类是导入哪个包?
- 用ASP.NET2.0生成WORD EXCEL文档
- 新手求解答 本人是新手有很多问题 求解答
- vs2005 sp1安装时总显示正在提取,一点不动好几个小时了
- 小问题,又来散分了!
- 高分求C#写的DataGrid有分页的,多选删除代码
- 如何把2035-1-1 0:00:00从数据库里读出后,赋予一个label后转换成2035年1月1号
- 问一个正则问题,嵌套匹配的
- 我是新手!我郁闷!我散分!
- 急!知道了一个图片的URL,如http://www.adasheriff.org/Databases/SexOffender/Photo-Thumbnail/SB2WALSHB.JPG,如何用C#代码把它存到数据
- treeview怎么定义对齐方式
MyDataGrid.DataSource=dv;
if(dv.Count % MyDataGrid.PageSize ==0)
{
iPagecount=dv.Count/MyDataGrid.PageSize;
}
else
{
iPagecount=dv.Count/MyDataGrid.PageSize+1;
}
if(iPagecount>iPageindex)
{
MyDataGrid.DataBind();
}
else
{
if(iPagecount>0)
{
MyDataGrid.CurrentPageIndex=iPagecount-1;
}
else
{
MyDataGrid.CurrentPageIndex=0;
}
MyDataGrid.DataBind();
}
int int_PageLess;
if(this.dGridUser.CurrentPageIndex == this.DGrid_Process.PageCount-1)
{
if(this.dGridUser.CurrentPageIndex == 0)
{
this.dGridUser.CurrentPageIndex = this.dGridUser.PageCount - 1;
}
else
{
if(this.dGridUser.Items.Count % this.dGridUser.PageSize == 1)
{
int_PageLess = 2;
}
else
{
int_PageLess = 1;
}
this.DGrdGridUser.CurrentPageIndex = this.dGridUser.PageCount - int_PageLess;
}
}
如果最后一页只有一条记录,删除后,DataGrid的CurrentPageIndex要减去2