Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Which button was clicked and on which row?

Reply
Thread Tools

Which button was clicked and on which row?

 
 
Yossi
Guest
Posts: n/a
 
      11-17-2006
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?



 
Reply With Quote
 
 
 
 
Yossi
Guest
Posts: n/a
 
      11-17-2006
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.


"Yossi" <> wrote in message
news:uczev%...
>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?
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
One button to know which button got clicked? bthumber ASP .Net 4 06-25-2010 05:36 PM
Spring java Controller get correct data from button when "apply"button is clicked but not pressing the <Enter> key albert kao Java 1 04-10-2010 02:54 AM
How could fire both TextChanged event and button click if button is clicked dyw55a@yahoo.com Javascript 0 06-01-2006 02:28 PM
Inconsistent behavior of an asp.net button performing a postback when a button is clicked. Mossman ASP .Net 0 12-12-2005 02:55 AM
Button Collection for Toolbar WebControl - Determinine which button was clicked Jim Mitchell ASP .Net Web Controls 0 07-12-2003 01:02 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57