<p>In ASP.NET, if I databind a gridview with a array of objects lets say , how can I retrieve and use foo(index) when the user selects the row?</p>

<p>i.e.</p>

<pre><code>dim fooArr() as foo;
gv1.datasource =  fooArr;
gv1.databind();
</code></pre>

<p>On Row Select</p>

<pre><code>Private Sub gv1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gv1.RowCommand

        If e.CommandName = "Select" Then
            'get and use foo(index)    
        End If
    End Sub
</code></pre>

in theory the index of the row, should be the index of foo (maybe +1 for header row, you'll need to test). so, you should be able to do something along these lines
```
```
dim x as object = foo(e.row.selectedIndex)
```
```
The other alternative is to find a way to databind the index to the commandArgument attribute of the button.