Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / DataGrid / November 2006

Tip: Looking for answers? Try searching our database.

Which button was clicked and on which row?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Yossi - 17 Nov 2006 15:47 GMT
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?
Yossi - 17 Nov 2006 16:46 GMT
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?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.