Grab Item from GridView

jlcruzAME

Member
Joined
Oct 18, 2012
Messages
21
Programming Experience
1-3
On a page that I have a gridview, one of the columns is a link for the user to open another page to upload files. Is there a way to grab a value out of the row that is clicked on? One of the columns is an ID number I need to grab when they click on this link, if possible. Here is the code for the column:

VB.NET:
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButtonUp" runat="server" CausesValidation="False" CommandName="OpenUp" OnClick="LinkButtonUp_Click1" Text="Submit Pictures" ForeColor="#0000CC"></asp:LinkButton>
                </ItemTemplate>

I've done some research and have found some things for C# but nothing in VB.

On the on click event I tried something like Me.GridView1.SelectedDataKey(1) but I get an error when it tries to run. It was under this section:

VB.NET:
    Protected Sub LinkButtonUp_Click1(ByVal sender As Object, e As System.EventArgs)
        Dim picAddress As String




        picAddress = "http://localhost:54007/Crews/Pics.aspx?value1=" + woNumber
        Process.Start(picAddress)
    End Sub
 
Last edited:
An update on the code. Here is what I have now:

VB.NET:
    Protected Sub LinkButtonUp_Click1(ByVal sender As Object, e As System.EventArgs)
        Dim picAddress As String
        Dim woNumber As String
        Dim row As GridViewRow
        row = GridView1.Rows(0)
        woNumber = row.Cells(5).Text

So far I still haven't found anything that will give me the row number of the row in which I'm clicking on the link. I keep finding C# code that is similar but I don't know how to convert it to VB.NET. Any help is appreciated.
 
VB.NET:
[COLOR=#000088]protected[/COLOR][COLOR=#000088]void[/COLOR][COLOR=#000000] button_Click1[/COLOR][COLOR=#666600]([/COLOR][COLOR=#000088]object[/COLOR][COLOR=#000000] sender[/COLOR][COLOR=#666600],[/COLOR][COLOR=#660066]System[/COLOR][COLOR=#666600].[/COLOR][COLOR=#660066]EventArgs[/COLOR][COLOR=#000000] e[/COLOR][COLOR=#666600])[/COLOR][COLOR=#000000]
    [/COLOR][COLOR=#666600]{[/COLOR][COLOR=#000000]
        [/COLOR][COLOR=#880000]//Get the button that raised the event inside your Gridview[/COLOR][COLOR=#000000]
        [/COLOR][COLOR=#660066]Button[/COLOR][COLOR=#000000] btn [/COLOR][COLOR=#666600]=[/COLOR][COLOR=#666600]([/COLOR][COLOR=#660066]Button[/COLOR][COLOR=#666600])[/COLOR][COLOR=#000000]sender[/COLOR][COLOR=#666600];[/COLOR][COLOR=#000000]
 
        [/COLOR][COLOR=#880000]//Get the row that contains this button[/COLOR][COLOR=#000000]
        [/COLOR][COLOR=#660066]GridViewRow[/COLOR][COLOR=#000000] gridviewRow [/COLOR][COLOR=#666600]=[/COLOR][COLOR=#666600]([/COLOR][COLOR=#660066]GridViewRow[/COLOR][COLOR=#666600])[/COLOR][COLOR=#000000]btn[/COLOR][COLOR=#666600].[/COLOR][COLOR=#660066]NamingContainer[/COLOR][COLOR=#666600];[/COLOR][COLOR=#000000]
 
        [/COLOR][COLOR=#880000]//Get the rowindex[/COLOR][COLOR=#000000]
        [/COLOR][COLOR=#000088]int[/COLOR][COLOR=#000000] rowindex [/COLOR][COLOR=#666600]=[/COLOR][COLOR=#000000] gridviewRow[/COLOR][COLOR=#666600].[/COLOR][COLOR=#660066]RowIndex[/COLOR][COLOR=#666600];[/COLOR][COLOR=#000000]
    [/COLOR][COLOR=#666600]}

[/COLOR]Can this code be done in VB.NET?
 
Back
Top