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 8146931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:10:32+00:00 2026-06-06T14:10:32+00:00

Every row in my gridview is supposed to have a button/hyperlink that navigates to

  • 0

Every row in my gridview is supposed to have a button/hyperlink that navigates to Page?id=something
Then there’s javascript that catches the redirect and prints the page as an iframe.
This something is and already available in the row (but hidden).
So i’d want to do something like NavigateUrl = “~/Page.aspx?id=” + Id.ToString() for each field, but the thing is the Id is populated in DataBind() from a LINQ datasource.

<asp:GridView ID="gridleitNidurstada" runat="server" GridLines="None" AllowPaging="True"
    CssClass="mGrid" PagerStyle-CssClass="pgr" DataKeyNames="Id" OnRowDataBound="gridLeit_RowDataBound"
    AllowSorting="True" SortedAscendingHeaderStyle-CssClass="sortasc-header" SortedDescendingHeaderStyle-CssClass="sortdesc-header"
    OnSorting="gridleitNidurstada_Sorting" CurrentSortField="Id" CurrentSortDir="Ascending"
    AutoGenerateColumns="False">
    <Columns>
        <asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" Visible="false"/>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:HyperLinkField HeaderText="Print" Text="Print" **anything here?**/>
    </Columns>
    <PagerStyle CssClass="pgr"></PagerStyle>
    <SortedAscendingHeaderStyle CssClass="sortasc-header"></SortedAscendingHeaderStyle>
    <SortedDescendingHeaderStyle CssClass="sortdesc-header"></SortedDescendingHeaderStyle>
</asp:GridView>

Binding is something like this: Could i do it there?
Or in the rowbound event?

IQueryable<model.SomeClass> someClass = 
    from m in preparePredicate()
    select new model.SomeClass
    {
        Id = m.id,
        ...
    };
        gridleitNidurstada.DataSource = someClass;
        gridleitNidurstada.DataBind();
  • 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-06T14:10:36+00:00Added an answer on June 6, 2026 at 2:10 pm

    You can use the following syntax:

    <asp:HyperLinkField DataNavigateUrlFields="col1,col2" DataNavigateUrlFormatString="gotopage.aspx?p1={0}&p2={1}" Text="Print">
    

    More information here and here on MSDN.

    EDIT:


    If you don’t know the exact url when creating the grid, you’ll have to do a bit more work.
    An example I’ve worked on this week, using an itemtemplate. But in order to use this, you have to set EnableSortingAndPagingCallbacks to false. And do some extra work in code behind for this.
    I’ve only used paging on my grid, so this sample I can provide.
    Markup:

    <asp:GridView ID="gridViewTicketsClosed" runat="server" CellPadding="4" ForeColor="#333333"
        GridLines="None" EnableSortingAndPagingCallbacks="False" AutoGenerateColumns="False"
        AllowPaging="True" OnRowDataBound="gridViewTicketsClosed_RowDataBound" OnPageIndexChanging="GridViewPageIndexChanging">
        <PagerSettings Mode="NextPrevious" NextPageText="Next" PreviousPageText="Previous" />
        <Columns>
            <asp:BoundField DataField="TicketId" HeaderText="Nr.">
                <ItemStyle Width="20px" />
            </asp:BoundField>
            <asp:BoundField DataField="DateStarted" DataFormatString="{0:dd/MM/yyyy HH:mm}" HeaderText="Date">
                <ItemStyle Width="100px" />
            </asp:BoundField>
            <asp:BoundField DataField="President" HeaderText="President">
                <ItemStyle Width="100px" />
            </asp:BoundField>
            <asp:BoundField DataField="TicketTypeId" HeaderText="TicketType"></asp:BoundField>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:HyperLink ID="lnkActionLog" runat="server" Text="Log"></asp:HyperLink>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    

    Code behind:

    protected void gridViewTicketsClosed_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            var hyperLink = e.Row.FindControl("lnkActionLog") as HyperLink;
            if (hyperLink != null)
                hyperLink.NavigateUrl = CreateShowActionLogUrl(e.Row) + "?id="+ DataBinder.Eval(e.Row.DataItem, "TicketId");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I have a gridview that I page through the server instead of in
I have a GridView that allows editing the values in every column, in every
I have a checkbox and a textbox in a GridView (for every row), and
Is there a way to avoid postbacks with gridview every time a row is
I have a gridview in which every row contains a dropdownlist. I want to
I having the page in that i have the gridview and page index changing
i have a gridview that creates a new row with a new gridview in
Why does every row have a red background when I'm using nth-child(odd) ? <div
I have a table where every row has a unique id. The last table
The Setup: I currently have a page with a GridView control on it inside

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.