In multiple pagins of DataGrid, the last record of the last page will often appear:
Invalid CurrentPageIndex value. It must be greater than or equal to 0 and less than PageCount.
Description: Execute an unprocessed exception during the current web request. Check the stack tracking information to learn more about the error and the code caused in the code.
Abnormal Details: System.Web.httpexception: Invalid CurrentPageIndex Value. It must be greater than or equal to 0 and less than PageCount.
Now just add the following code, add it to the DataGrid's deleteCommand event, you can completely resolve an exception.
Note: [protected system.web.ui.webcontrols.dataGrid DG];
IF ((Dg.CurrentPageIndex == DG.PageCount-1) && Dg.Items.count == 1)
{
IF (Dg.CurrentPageIndex-1> 1)
{
Dg.currentPageIndex = DG.CurrentPageIndex-1;
}
Else
{
Dg.currentPageIndex = 0;
}
}
this.open_sql ();
Dg.DATABIND ();