请问为什么RowDeleteing成功删除了记录,但是不能触发RowDeleted事件呢?
是RowDeleteing中没有设置主键的原因吗?RowDeleteing能正确删除记录,但是之后页面没有弹出"删除成功"
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int index = e.RowIndex;//取得当前行号,并取得当前行的GridViewRow对象
GridViewRow gvR = GridView1.Rows[index];
//取得当前行第三个单元格中的文字
string deleteItem = gvR.Cells[2].Text;
string strCon = "Data Source=.;" +
"Initial Catalog=studentManageSystem;" +
"Integrated Security=True;";
string strSQL = string.Format("delete from studentScoreInfo where Sno='{0}'", deleteItem);
SqlConnection con = new SqlConnection(strCon);
con.Open();
SqlCommand cmd = new SqlCommand(strSQL, con);
cmd.ExecuteNonQuery();
}
protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
{
if (e.Exception == null)
{
Response.Write("<script type='text/javascript'>alert('删除成功!')</script>");
.......
..........
.........
}
else
{
Response.Write("<script type='text/javascript'>alert('删除失败!')</script>");
}