Results 1 to 4 of 4

Thread: [Resolved] [2005] gridview button click, what button was clicked?

  1. #1

    Thread Starter
    Addicted Member DemonMade's Avatar
    Join Date
    Dec 2003
    Location
    Holt. MI
    Posts
    179

    Resolved [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.

  2. #2
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    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

  3. #3

    Thread Starter
    Addicted Member DemonMade's Avatar
    Join Date
    Dec 2003
    Location
    Holt. MI
    Posts
    179

    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.

  4. #4
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    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
  •  



Click Here to Expand Forum to Full Width