且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何添加弹出窗口以从gridview中删除行?

更新时间:2023-12-05 07:54:52

请尝试如下(示例) 。

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?');";
    }
}