2.20. Adding a Delete Confirmation Pop-Up
You want to add to a
GridView row a confirmation pop-up that appears whenever a user tries to delete a row in the
Add a Select button to each row of the
GridView and a Delete button below the
GridView. Whenever the Delete button is clicked, execute some client-side script that displays the confirmation pop-up, followed by some server-side code that performs the actual deletion.
In the .aspx file:
Create an extra button column in the
GridViewto display a Select button.
Add a Delete button below the
In the code-behind class for the page, use the .NET language of your choice to:
Register the client-side script to be executed when the Delete button is clicked.
Add an attribute to the Delete button that calls the delete script when the Delete button is clicked.
Figure 2-22. Confirmation pop-up before deletion in a GridView output
To display a confirmation pop-up when a user attempts to delete a row in a data table, you create a
GridView in the same way you have done throughout this chapter, except that you add a button column to allow for row selection. Setting the
ButtonType to "
Link" outputs a hyperlink for selecting the row. (The ...