Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8829943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:57:08+00:00 2026-06-14T07:57:08+00:00

I have a gridview to display request information from a table. I have added

  • 0

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

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

My gridview

<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"> 
    <AlternatingRowStyle BackColor="White" />
    <Columns>

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






<asp:SqlDataSource ID="analystdefaultview" runat="server" 
    ConnectionString="<%$ ConnectionStrings:Underwriting %>" 
    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" >


    <SelectParameters>
        <asp:ControlParameter ControlID="chooseanalyst" DefaultValue="1" Name="opaid" 
            PropertyName="SelectedValue" />
    </SelectParameters>

</asp:SqlDataSource>

</div>

.cs file – The roc_id is the variable that i need to pass to the url

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

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:57:09+00:00Added an answer on June 14, 2026 at 7:57 am

    You need RowCommand event, along with CommandArgument for passing value in RowCommmand event.

    Html

    <ItemTemplate>
               <asp:Button ID = "button2" runat = "server" CommandName="cmdYourButtonPurpose" CommandArgument='<%# Bind("roc_id") %>'
                    Text='<%# Bind("roc_id") %>' />
    </ItemTemplate>
    

    Code Behind

    void ContactsGridView_RowCommand(Object sender, GridViewCommandEventArgs e)
    {
         if(e.CommandName=="cmdYourButtonPurpose")
         {   
             Response.Redirect("http://xxx.yahoo.com/testing/adhoc/Edit.asp?ROCID=" + e.CommandArgument.ToString(););
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

want to have a Hyperlink-Button in a gridView in which I can display a
I have a gridview which should display only usernames based on the email written
I have an asp.net web form. I used Gridview to display the table from
I have a ListView which is using a GridView to display a DataTable and
I have a gridview that displays items details, I added two template fields one
I have a master-detail page, in which I use GridView to display multiple rows
In my aspx page I have a gridview which displays the value from my
I have a gridview which I am using to display a dataset result. The
I have an extended GridView class, GridViewEx, which inherits from the basic ASP.NET gridview.
I have a page that uses GridView to display some data taken from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.