我在updatePanel 里 放了GridView 点删除时 我想 弹出 对话框,问是否删除,怎么写

解决方案 »

  1.   

    删除按钮 : onclientclick=“return confirm('确定删除吗?')"
      

  2.   

    用javascript实现,confirm("确定删除?"),你查找一下相关资料!
      

  3.   

    在GridView1_ItemCreated事件里
    通过e,findcontrol出你的删除按钮
    假设删除按钮定义为 btnDel
    再写一句:btnDel.Attributes.Add("onclick", "return confirm('确定要删除吗?')")就可以了
      

  4.   

    在ondatabounding 还是ondatabound的事件中,foreach 每行里找到button1, 
    Button1.Attributes.Add("onclick", "alert('确定要删?)");
      

  5.   

    OnClientClick="return confirm('确定删除吗?')"
      

  6.   

    OnClientClick="return confirm('确定要删除吗?');"
      

  7.   

    ScriptManager.RegisterStartupScript(自己看参数);
      

  8.   

    参考这个  
       比上面的都简单
    也实用
    http://www.cnblogs.com/doraeimo/archive/2007/01/01/609344.html
      

  9.   

    貌似上面记差了,
    那个在Page_Load里面就必须添加attribute.也就是在绑定girdview之后然后紧接着
     GridView1.DataBind();
            foreach (DataGridItem dr in GridView1.Rows)
            {
                Button btn = (Button)dr.Cells[1].FindControl("Button1");
                btn.Attributes.Add("onclick", "alert(“确定要删么?')");        }-_-#很久以前写的,具体在gridview row里找控件记不清了,找到button后就可以添加确认。
      

  10.   

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 
            { 
                if (e.Row.RowType == DataControlRowType.DataRow) 
                { 
                    e.Row.Cells[0].Attributes.Add("onclick", "return confirm('你确认要删除吗?')");             }         }
      

  11.   

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                Button btnDel = e.Row.FindControl("btnDel") as Button;
                if (btnDel != null)
                {
                    btnDel.Attributes.Add("onclick", "return confirm('确认删除吗?')");
                }
            }书上的写法。
      

  12.   

    <asp:TemplateField ShowHeader="False"> 
                                        <ItemTemplate> 
                                        <asp:LinkButton ID="lkButton" runat="server" CausesValidation="False" 
                                        CommandName="Delete" 
                                        onclientclick="return confirm(&quot;Are you sure to delete?&quot;)" Text="Delete"></asp:LinkButton> 
                                        </ItemTemplate> 
                                    </asp:TemplateField>
      

  13.   


    如果你对这些JS不熟悉的话用ConfirmButton 就行了(记得转为模版列)