1.模板列。

<asp:LinkButton ID="LinkButton2" runat="server" CommandName="delete" CausesValidation="False"  OnClientClick="return confirm('确认要删除吗?');">删除</asp:LinkButton>

2.非模板列

在RowDataBound事件中进行,若Delete按钮是LinkButton,并且在第3列,代码如下:

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

 

posted on 2016-04-25 09:22  来一瓶三鹿  阅读(649)  评论(0)    收藏  举报