Set the CommandName property of the two buttons eg button1.CommandName =
"This" button2.CommandName = "That"
handle the RowCommand of the GridView and switch through the commandnames
I am talking here about the GridView component in ASP .Net 2.0. When I look
at the source for the GridView, I see two <asp:ButtonField....> elements.
If I add a CommandArgument attribute, I get an error. It seems that
ButtonFields do not have a CommandArgument attribute.
To determine the index of the record that raises the command event, use the
CommandArgument property of the event argument that is passed to the command
event for the data-bound control. The ButtonField class automatically
populates the CommandArgument property with the appropriate index value.
Intellisense was not showing me a CommandArgument. That is why I got
confused. Now all I have to do is set different CommandNames for each
button in order to determine which one was clicked. Before, I set the
CommandName of both buttons to Select and then I was handling the
OnSelectedIndexChanged event. That was giving me the row, but not which
button fired the select.
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.