It was working fine and then boom all the sudden started to get this message. I have not enabled anthing in the datagrid to be deleted or updated yet, the error starts from the page load. When i click on a page number it throw the error.
Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount.
I have looked at several solution but non seem to work, don't know why. the follwoing is my code for my pageindexchanged. I added the if then else statment to try to resolve issue but I still get the error.
Private Sub myDataGrid_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles myDataGrid.PageIndexChanged
'Enable datagrid paging
If myDataGrid.CurrentPageIndex >= myDataGrid.PageCount Then
myDataGrid.CurrentPageIndex = myDataGrid.PageCount - 1
myDataGrid.CurrentPageIndex = e.NewPageIndex
myDataGrid.DataSource = myDataTable