I have GridView with several text columns and 2 buttons. How do I determine
which button on which row was clicked.
I am able to detect a button clicked if I set the CommandText to "Select".
All I have to do is write an event handler for the SelectedIndexChanged
event and I get to know on which row the button was clicked. But how do I
tell whether the first or second buttons where clicked?
I found the answer in the MSDN:
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.
>I have GridView with several text columns and 2 buttons. How do I
>determine
[quoted text clipped - 4 lines]
> event and I get to know on which row the button was clicked. But how do I
> tell whether the first or second buttons where clicked?