I'm using a DataGrid control with paging.
Say that I have 10 records per page. If I have 21 records, there will only be one record on the 3rd page. If I delete that record there is no more records on that page and I get an error back from the datagrid "Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount" as can be expected.
I tried comparing datagrid.pagecount to datagrid.currentPageIndex just before I call the datagrid.DataBind, but it looks like the pagecount is only calculated during the databind (which makes sense).
So, without going through the hassle of manually calculating how many records I have in my dataset compared to my number of pages/number or items per page... How do I make my page go to the previous page when the last record on the current page is deleted?