看我删除按钮里代码如下:
private void Button1_Click(object sender, System.EventArgs e)
{
OleDbConnection myConn=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("data/pc.mdb"));
string strSql="select * from pc";
OleDbDataAdapter myComm=new OleDbDataAdapter(strSql,myConn);
DataSet ds=new DataSet();
myComm.Fill(ds,"name");
for(int i=0;i<DataGrid1.Items.Count;i++)
{
CheckBox cb=(CheckBox)DataGrid1.Items[i].FindControl("chkExport");
if(cb.Checked)
{
ds.Tables["name"].Rows[i].Delete();
}
}


OleDbCommandBuilder nameCmdBd=new OleDbCommandBuilder(myComm);
myComm.Update(ds,"name");
DataGrid1.DataSource=ds.Tables["name"].DefaultView;
DataGrid1.DataBind();
int lastEditedPage=DataGrid1.CurrentPageIndex;
if((DataGrid1.PageCount-DataGrid1.CurrentPageIndex)==1 && DataGrid1.Items.Count== 1)
{
if(DataGrid1.PageCount>1)
{
lastEditedPage=lastEditedPage-1;
}
else
{
lastEditedPage=0;
}
DataGrid1.CurrentPageIndex= lastEditedPage;
}
}
-------------------------------------------
在选中CHECKBOX中一条一条记录删除,直得删除一页中最后一条时可以向上返页,但是一下子把当前页中的所以记录全选,然后按删除时就出现以下错误不能向上返页????
-----------------------------------
“/Newnet”应用程序中的服务器错误。
--------------------------------------------------------------------------------无效的 CurrentPageIndex 值。它必须大于等于 0 且小于 PageCount。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Web.HttpException: 无效的 CurrentPageIndex 值。它必须大于等于 0 且小于 PageCount。源错误: 
行 122: myComm.Update(ds,"name");
行 123: DataGrid1.DataSource=ds.Tables["name"].DefaultView;
行 124: DataGrid1.DataBind();
行 125: int lastEditedPage=DataGrid1.CurrentPageIndex;
行 126: if((DataGrid1.PageCount-DataGrid1.CurrentPageIndex)==1 && DataGrid1.Items.Count== 1)
 源文件: F:\homework\netbest\Newnet\CheckBox.aspx.cs    行: 124