string strdel="delete from dzs_sb where pmid='"+e.Item.Cells[0].Text+"'";
SqlCommand mycomm=new SqlCommand(strdel,myconn);
mycomm.ExecuteNonQuery();
sbgrid.EditItemIndex=-1;
datagrid.datasource=???;datagrid.databind();

解决方案 »

  1.   

    重新绑定之前加一句
    DataGrid1.CurrentPageIndex = 0
    然后再重新绑定
      

  2.   

    我是说删除的代码写在哪?
    写在DataGrid1_ItemCommand 中时
    无论删不删
    当要显示下一页时,都出错??
    怎么回事?
    谢谢?
      

  3.   

    感谢kerling78(kerling)!
    我还想问一下,我想在删除前做个提示框,让用户确定是否删除该条记录,代码如何写?
      

  4.   

    e.Item.Cells(17).Attributes.Add("onclick", "return confirm('此操作将删除所有相关信息,您确定要删除这一项吗?');")
    写在DataGrid1_ItemDataBound中
    删除翻页后的数据时要重新绑定,判断一下
            If rs.Tables("info").Rows.Count Mod 10 = 0 Then
                Me.DataGrid1.CurrentPageIndex = rs.Tables("info").Rows.Count / 10 - 1
            End If
      

  5.   

    感谢 zyrlxy(柔雨叶),能讲该代码的作用吗?
    e.Item.Cells(17).Attributes.Add("onclick", "return confirm('此操作将删除所有相关信息,您确定要删除这一项吗?');")