在做DataBind之前判断当前DataTable的数量:
If dtCart.Rows.Count = dgCart.PageSize * dgCart.PageCount And dgCart.CurrentPageIndex > 0 Then
dgCart.CurrentPageIndex = dgCart.CurrentPageIndex - 1
End If

解决方案 »

  1.   

    icyer:
    我讲你的代码放在了dgCart_ItemCommand()事件中的dtCart.DataBind()之前
    结果还是不行:-(
      

  2.   

    在绑定之前要重新设置grid的currpageindex,我一直是这样用的,可以肯定没有问题
           dgrdApplyList.DataSource = objDataView
            Dim intMaxPageIndex As Integer = (objDataView.Count - 1) \ dgrdApplyList.PageSize
            If dgrdApplyList.CurrentPageIndex > intMaxPageIndex Then
                dgrdApplyList.CurrentPageIndex = Math.Max(0, intMaxPageIndex)
            End If
            dgrdApplyList.DataBind()