how to pass the selected row id in a grid view value to a redirection url
<p>I have a gridview to display request information from a table.
I have added a button template feild which upon clicking should take the user to the appropriate request url</p>

<p>How do i capture the selected requestid and pass it on as a variable in my redirection url</p>

<p><strong>My gridview</strong></p>

<pre><code>&lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
    CellPadding="4" DataKeyNames="roc_id" DataSourceID="analystdefaultview" 
    ForeColor="#333333" GridLines="None" AllowPaging="True"  
    AllowSorting="True" Visible="False" 
        onselectedindexchanged="GridView1_SelectedIndexChanged"&gt; 
    &lt;AlternatingRowStyle BackColor="White" /&gt;
    &lt;Columns&gt;

               &lt;asp:CommandField ShowDeleteButton = "true"  /&gt;
        &lt;asp:TemplateField HeaderText="RequestId" SortExpression="roc_id"&gt;
            &lt;EditItemTemplate&gt;
                &lt;asp:HyperLink ID="HyperLink1" runat="server" Text='&lt;%# Bind("roc_id") %&gt;'&gt;&lt;/asp:HyperLink&gt;
            &lt;/EditItemTemplate&gt;
            &lt;ItemTemplate&gt;
               &lt;asp:Button ID = "button2" runat = "server" Text='&lt;%# Bind("roc_id") %&gt;' /&gt;
            &lt;/ItemTemplate&gt;
        &lt;/asp:TemplateField&gt;
        &lt;asp:BoundField DataField="fundtype" HeaderText="fundtype" 
            SortExpression="fundtype" /&gt;
        &lt;asp:BoundField DataField="productionmth" HeaderText="productionmth" 
            SortExpression="productionmth" /&gt;
        &lt;asp:BoundField DataField="targetdt" HeaderText="targetdt" 
            SortExpression="targetdt" ReadOnly="True" /&gt;
        &lt;asp:BoundField DataField="actualdt" HeaderText="actualdt" 
            SortExpression="actualdt" ReadOnly="True" /&gt;
        &lt;asp:BoundField DataField="freqcd" HeaderText="freqcd" 
            SortExpression="freqcd" /&gt;
        &lt;asp:BoundField DataField="entereddt" HeaderText="entereddt" 
            SortExpression="entereddt" ReadOnly="True" /&gt;
        &lt;asp:BoundField DataField="groupcnt" HeaderText="groupcnt" 
            SortExpression="groupcnt" /&gt;
        &lt;asp:BoundField DataField="rptrsrcetxt" HeaderText="rptrsrcetxt" 
            SortExpression="rptrsrcetxt" /&gt;
        &lt;asp:BoundField DataField="dateavailable" HeaderText="dateavailable" 
            SortExpression="dateavailable" ReadOnly="True" /&gt;
        &lt;asp:BoundField DataField="groupname" HeaderText="groupname" 
            SortExpression="groupname" /&gt;
        &lt;asp:BoundField DataField="groupnbr" HeaderText="groupnbr" 
            SortExpression="groupnbr" /&gt;
        &lt;asp:BoundField DataField="datarecpdet" HeaderText="datarecpdet" 
            SortExpression="datarecpdet" /&gt;
    &lt;/Columns&gt;
    &lt;EditRowStyle BackColor="#2461BF" /&gt;
    &lt;FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /&gt;
    &lt;HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /&gt;
    &lt;PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" /&gt;
    &lt;RowStyle BackColor="#EFF3FB" /&gt;
    &lt;SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" /&gt;
    &lt;SortedAscendingCellStyle BackColor="#F5F7FB" /&gt;
    &lt;SortedAscendingHeaderStyle BackColor="#6D95E1" /&gt;
    &lt;SortedDescendingCellStyle BackColor="#E9EBEF" /&gt;
    &lt;SortedDescendingHeaderStyle BackColor="#4870BE" /&gt;
&lt;/asp:GridView&gt;






&lt;asp:SqlDataSource ID="analystdefaultview" runat="server" 
    ConnectionString="&lt;%$ ConnectionStrings:Underwriting %&gt;" 
    SelectCommand="SELECT
       [roc_id]
       ,[fundtype]
       ,Convert(varchar(20),[prodmth],111) as productionmth
       ,Convert(varchar(20),[targetdt],111) as targetdt
       ,Convert(varchar(20),[actualdt],111) as actualdt
       ,[freqcd]
       ,Convert(varchar(20),[entereddt],111) as entereddt
       ,[groupcnt]
       ,[rptrsrcetxt]     
       ,Convert(varchar(20),[date_available],111) as dateavailable
       ,[groupname]
       ,[groupnbr]
       ,[datarecpdet]


        from renoffcyc where opa_id = @opaid and YEAR(prodmth) = YEAR(getdate()) AND MONTH(prodmth) = MONTH(getdate())"

     DeleteCommand = "DElete from renoffcyc where  roc_id = @roc_id" &gt;


    &lt;SelectParameters&gt;
        &lt;asp:ControlParameter ControlID="chooseanalyst" DefaultValue="1" Name="opaid" 
            PropertyName="SelectedValue" /&gt;
    &lt;/SelectParameters&gt;

&lt;/asp:SqlDataSource&gt;

&lt;/div&gt;
</code></pre>

<p><strong>.cs file</strong> - The roc_id is the variable that i need to pass to the url</p>

<pre><code> protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Response.Redirect("http://xxx.yahoo.com/testing/adhoc/Edit.asp?ROCID=roc_id");

    }
</code></pre>
