VB.Net GridView CommandField Delete Command in ASP.Net

ASP.Net GridView control provides a CommandField whose events can be handled at server side using VB.Net that enables you to display the Delete Command button also which can be used to call the delete command at server side to permanently delete the record from the database. You can easily attach the GridView event such as RowDeleting to implement the delete command of GridView control.

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 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