Thursday, October 27, 2011 GridView delete confirmation

    How to ask for confirmation when using the delete command in gridview? By default it just deletes the item right away.

Answer: Disable the "Show Delete" Option and Put below code in the grid template.          

                         <asp:LinkButton ID="lnkDeleteBtn" Runat="server" OnClientClick="return ConfirmDelete();"

Also put this piece of javascript in the header section.
"<script type="text/javascript">
    function ConfirmDelete() {
        return confirm("Are you sure to delete?");

No comments:

Post a Comment