方法一:
我在添加了模版列按钮,用到了按钮的onclick和 OnClientClick事件,在客户端点击事件提示确认,在服务端点击事件执行,现在是这个服务端事件不知道怎么获取gridview所选择行索引.
方法二:
要是直接用gridview的删除按钮,又会直接的执行RowDeleting事件,不会弹出删除确认.
=============================================================================
郁闷,好怀念我的datagrid啊!

解决方案 »

  1.   

    你还是VS2.0还是可以使用DataGrid,你把控件直接添加到工具箱就是
      

  2.   

    嗯,老是觉得gridview不好用,有谁能帮我解决这问题吗?
      

  3.   

    在前台属性中写入:OnClientClick="return confirm('Do you want to remove the record?')" CommandName="DeleteTheRecord"
    后台在GridView1_RowCommand事件里:
    if (e.CommandName == "DeleteTheRecord")
                    {
                        int index = Convert.ToInt32(e.CommandArgument);
                        int a = Convert.ToInt32(GridView1.DataKeys[index].Value.ToString());
                        this.DeleteMethod(a);
                    }
      

  4.   

    <asp:TemplateField HeaderText="删除">
    <ItemStyle HorizontalAlign="Center"></ItemStyle>
    <ItemTemplate>
    <asp:LinkButton ID="btnDelete" runat="server" CausesValidation="false" CommandName="Delete" Text="删除"></asp:LinkButton>
    </ItemTemplate>
    </asp:TemplateField>      protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                    if (e.Row.RowType == DataControlRowType.DataRow)
                    {
                        e.Row.Attributes["onmouseover"] = "javascript:this.style.backgroundColor='#eeeeee';";
                        e.Row.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#ffffff';";                    LinkButton btnDel = (LinkButton)e.Row.Cells[7].Controls[1];
                        btnDel.Attributes.Add("onclick", "return confirm('确定要删除这个用户吗?');");
                    }
            }
      

  5.   

    怎么我的点击模版列的按钮不会触发rowcommand事件呢?
      

  6.   

    在GridView的属性里写OnRowCommand="GridView1_RowCommand"
    后台事件:protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {

    }
      

  7.   

    我的是有OnRowCommand这个事件,用gridview自带的选择按钮可以触发事件的,就是这个模版列按钮不能触发啊!
      

  8.   

    <asp:TemplateField HeaderText="删除">
    <ItemStyle HorizontalAlign="Center"></ItemStyle>
    <ItemTemplate>
    <asp:LinkButton ID="btnDelete" runat="server" CausesValidation="false" CommandName="Delete" Text="删除" onClientClick="return confirm('确定要删除吗?')"></asp:LinkButton>
    </ItemTemplate>
    </asp:TemplateField>
      

  9.   

    搞了半天,原来非要<asp:LinkButton>这种按钮才起作用,换成这种<asp:Button>类型,就不会触发rowcommand.真是奇怪..............