Creating a DeleteButtonField

I don’t like the Delete button rendered by the GridView control’s CommandField. The problem is that it does not provide you with any warning before you delete a record. In this section, we fix this problem by creating a Delete button that displays a client-side confirmation dialog box (see Figure 11.24).

Figure 11.24. Displaying a confirmation dialog box.

image

DeleteButtonField inherits from the ButtonField class. The code for the custom field is contained in Listing 11.33.

Listing 11.33. DeleteButtonField.cs

images

Most of ...

Get ASP.NET 4 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.