如何添加弹出窗口以从gridview中删除行? [英] How to add the pop up for deleting the row from the gridview?

查看:74
本文介绍了如何添加弹出窗口以从gridview中删除行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何显示以下代码的弹出窗口

How to show popup for the following code

<asp:CommandField ShowDeleteButton="True"   >
                                <HeaderStyle Width="30px" />
                                </asp:CommandField>

推荐答案

请尝试如下(示例) 。

Please try is as below (sample).
<asp:LinkButton ID="lbDelete" runat="server" OnClientClick="return confirm('Are you sure want to delete the Corporate Action?')" CausesValidation="False"

                                           CommandName="Delete" Text="Delete"></asp:LinkButton>





欲了解更多信息: 弹出确认



弹出编辑/添加/删除记录GridView [ ^ ]



For more info : Popup confirmation

Popup Editing/Adding/Deleting Records with GridView[^]


您应该使用javascript在客户端执行此操作。



因此您可以处理GridView的RowDataBound事件将其添加到Delete-Button的OnClientClick:





You should do that on clientside with javascript.

Therefore you can handle GridView's RowDataBound event to add this to the Delete-Button's OnClientClick:


protected void gvShowQuestionnaires_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        // reference the Delete LinkButton
        LinkButton db = (LinkButton)e.Row.Cells[3].Controls[0];

        db.OnClientClick = "return confirm('Are you certain you want to delete this questionnaire?');";
    }
}


这篇关于如何添加弹出窗口以从gridview中删除行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆