GridView的删除提示有关问题

GridView的删除提示问题
本帖最后由 bulls5988 于 2015-07-08 16:46:01 编辑
用GIRDVIEW里面的删除按钮,ButtonType是Button;
现在点击删除按钮的时候,会提示:'你确定要删除吗?";
但是无选是还是否数据都会做删除操作,请问如何解决这个问题?就算点击右上角的关闭窗口也会删除数据。
下面是删除代码。

 <asp:CommandField HeaderText="操作" ShowDeleteButton="True" 
 DeleteText ="删除" ButtonType="Button"/>



protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onmouseover", 
           "currColor=this.style.backgroundColor; this.style.backgroundColor='#ccccff'
;");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currColor"
);
            e.Row.Cells[4].Attributes.Add("onclick", "return confirm('你确定要删除吗?')
");
        }
    }

------解决思路----------------------
return confirm('你确定要删除吗?'

在网站里写这样的代码是在自欺欺人呢

想让客户端(IE)判断是否要删除,你必须在前台页面写JS,而不是在后台拼接

因为网站是客户端-服务端的通信程序,并不是单机程序

等你看到这个提示,服务端那面早都执行完了,而不是在等你确认才继续往下执行