标题:请问为什么RowDeleteing成功删除了记录,但是不能触发RowDeleted事件呢?
只看楼主
hellenism
Rank: 1
等 级:新手上路
帖 子:86
专家分:0
注 册:2009-2-27
结帖率:76.47%
已结贴  问题点数:10 回复次数:1 
请问为什么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>");
        }
搜索更多相关主题的帖子: 触发 记录 RowDeleteing RowDeleted 删除 
2010-05-28 18:14
mijia
Rank: 2
等 级:论坛游民
帖 子:55
专家分:86
注 册:2010-5-13
得分:7 
有这个con.Open();应该也要有这个吧close.Open()
2010-05-28 19:41



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-308530-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.196499 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved