I recently had the requirement to provide multiple select-type commands on an ASP.NET GridView that each resulted in a different action. Using an only provides you with the ability to have a single select, single delete, and single edit command. You cannot have multiples of each. I did, however, discover the . Using the you can assign a command name to each button (which can be a regular button, image button, or link button) and execute the appropriate code accordingly.

In your add an OnRowCommand call:

Add your (you can do this with the WYSIWYG in Visual Studio as well):

In your code-behind, you simply need to use an “If” or a “Switch” to determine which command to execute:

That’s it. It’s rather simple and it helped me, so I wanted to share. Hopefully you find it useful.

Source


Pin It on Pinterest

Share This
%d bloggers like this: