string sql = "delete  from food where foodName='" + GridView1.DataKeys[e.RowIndex].Value.ToString() +"'";
        SqlConnection con = new SqlConnection(constr);
        con.Open();
        SqlCommand cmd = new SqlCommand(sql, con);
        int i = cmd.ExecuteNonQuery();
        if (i>0)
        {
            Response.Write("<script>alert('删除成功')</script>");
        }
        else
        {
            Response.Write("<script>alert('删除失败')</script>");
        }
        con.Close();
        Page_Load(sender,e);这是GridView的删除按钮触发的RowDeleting事件代码,为什么每次我删除一条数据,执行了RowDeleting事件,我刷新网页他又执行一次RowDeleting事件,我继续刷新他就继续执行RowDeleting事件。。
这是什么情况?

解决方案 »

  1.   

    把Page_Load(sender,e);改成Response.Redirect("你的页面地址");试试
      

  2.   

    Page_Load( sender,  e)的问题吧
      

  3.   

    Page_Load里面只是一个从数据库绑定数据到gridView中来而已,刷新再次执行 RowDeleting和和这个没有关系
      

  4.   

    page_load里面加
    if (!IsPostBack)
    这个了没有?然后再加上RowDeleting 事件
     //模拟网络拥塞5秒钟 
          System.Threading.Thread.Sleep(5000);
      

  5.   

    删除之后重新绑定 BindData();方法.. 这个方法写在page_load 里面(!IsPostBack){BindData();}...我想这样可能够清楚了吧!!!!