Datgrid currentPageIndex problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I am displaying data from database in datagrid. DG is having edit and
delete features. Pagesize is 10. I have total 12 records(2 pages). Now i am
deleting 12th and 11th records. Delete operation is successful. But, after
deleting the last record in the 2nd page, i am getting error " Invalid
CurrentPageIndex value. It must be >= 0 and < the PageCount." coz that is the
last record in that page but there are records in the prev page. What to do
to avoid that error?
 
When you rebind the grid set the page index back ...

if(CurrentPage !=0 && (CurrentPageIndex + 1) * PageSize > TotalItems) {
CurrentPageIndex = TotalItems/PageSize - 1;
}

You can also subclass DataGrid and put it in the datagrid directly.

Cheers,

Greg
 
Back
Top