|
-
Apr 7th, 2008, 08:01 PM
#1
Thread Starter
Addicted Member
[Resolved] [2005] gridview button click, what button was clicked?
I have a grid view with a Template Field, witch contains a button and a text box. What I need to know is either the row that contains the button that was clicked, or more specifically, the contents of the first column of the row that contains the button that was clicked. I would like to do this without needing the user to "select" the row, so gridview.selectedrow...
Any Ideas?
Last edited by DemonMade; Apr 8th, 2008 at 02:54 PM.
Reason: Resolved
No one is perfect, but it doesn’t hurt to try.
-
Apr 8th, 2008, 01:04 AM
#2
Re: [2005] gridview button click, what button was clicked?
The gridview_command event will not have any row information with it so you have to set the buttons command argument to the row index or some value you want. To set it to the row index do it in the rowdatabound event using findcontrol to locate the button
Code:
sub gv_rowdatbound(...........
If e.Row.RowType = DataControlRowType.DataRow Then
CType(e.Row.Cells(4).FindControl("btnID"), Button).CommandArgument = e.Row.RowIndex
End If
end sub
sub gv_rowcommand(.....
Dim myValue As String = GridView1.Rows(e.CommandArgument).Cells(0).Text
end sub
-
Apr 8th, 2008, 02:52 PM
#3
Thread Starter
Addicted Member
Re: [2005] gridview button click, what button was clicked?
Awsome! That seems to do it and you put it in very easy to understand terms. Thank you very much.
No one is perfect, but it doesn’t hurt to try.
-
Apr 8th, 2008, 07:27 PM
#4
Re: [Resolved] [2005] gridview button click, what button was clicked?
My pleasure, the same thing left me wondering why and looking for answers.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|