I need to create multiple actions for a gridview – say, “Approve”, “Deny”, and “Return”.
I can do this by creating a button field for each action:
<asp:ButtonField ButtonType="Link" CommandName="Approve" Text="Approve" />
<asp:ButtonField ButtonType="Link" CommandName="Deny" Text="Deny />
<asp:ButtonField ButtonType="Link" CommandName="Return" Text="Deny" />
However, this creates one column for each button.
Is there a way to have the same functionality, but combine them into a single column?
Have you considered using an
TemplateField? Here is an example:You can then capture the commands the exact same way using
OnRowCommandor do whatever you like. You have full control to make it behave how you need and not be bound by the built in functionality of using the regular predefined column types.