protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
e.Cancel = true;
int stuid = int.Parse( GridView1.Rows[e.RowIndex].Cells[0].Text);
string stuname = GridView1.Rows[e.RowIndex].Cells[1].Text;
int stuage = int.Parse( GridView1.Rows[e.RowIndex].Cells[2].Text);
string stucourse = GridView1.Rows[e.RowIndex].Cells[3].Text;
double stuscore = double.Parse( GridView1.Rows[e.RowIndex].Cells[4].Text);
stuinfoTableAdapter sAdapter = new stuinfoTableAdapter();
sAdapter.Delete(stuid, stuname, stuage, stucourse, stuscore);
setBind();
Response.Write( " <script> alert( '删除成功! ') </script> ");
}
------解决方案--------------------------------------------------------
e.Cancel = true;
return;
------解决方案--------------------------------------------------------
删除又取消?
lz是不是想做提示删除功能啊
------解决方案--------------------------------------------------------
Cancel不是cancel掉你下面的代码.而是cancel掉你在datasource控件里的deletecommand里所写的SQL语句..e.cancel=true;的作用就是可以让你自定义自己的删除语句..因为deletecommand只能执行一个SQL语句..例如你想删除某个文章系统的类别的同时也删除属于该类别下的文章.这时,deletecommand可能就解决不了问题,这时就得像你这样的解决方法了..在GridView1_RowDeleting里cancle掉内置的删除功能而自己写删除