VB.Net GridView Delete with JavaScript Confirm in ASP.Net

In GridView control you can add the Link Button control to implement the Javascript Confirm message box over the Delete command event. You can set the CommandName property of Link Button control equal to "Delete" to attach the RowDeleting event of GridView control that executes the server side VB.Net code for deleting the data record. The JavaScript confirm box shows two buttons such as Ok and Cancel. When the user clicks Cancel button then it prevents the server side event to occur whereas when user clicks the OK button then it permits the execution of server side VB.Net code to perform the delete action for the targeted record item.

Command Event Used

1. OnRowDeleting

 

GridView Property Used

1. DataKeys

 

The DataKeys property of GridView control enables you to hold the unique identifier values for each row generated inside it. The DataKey value can be retrieved using VB.Net for the associated row item that can be used to perform the delete action for that particalur row item in the database as well.

 

Try the sample below to understand the functionality developed using VB.Net code for GridView Control's delete Command along with JavaScript confirm message box in ASP.Net:

 

IDCategory NameDescription 
1 Beverages Soft drinks, coffees, teas, beers, and ales Delete
2 Condiments Sweet and savory sauces, relishes, spreads, and seasonings Delete
3 Confections Desserts, candies, and sweet breads Delete
4 Dairy Products Cheeses Delete
5 Grains/Cereals Breads, crackers, pasta, and cereal Delete
6 Meat/Poultry Prepared meats Delete
7 Produce Dried fruit and bean curd Delete
8 Seafood Seaweed and fish Delete

  • HIRE EzineASP.Net Developers