How to set Querystring values in <asp:HyperLinkField > in GridView

Posted on 2009-04-27
Last Modified: 2012-05-06
<asp:HyperLinkField NavigateUrl="~/test.aspx" ShowHeader="False" Text="View/Edit" />

<%# Eval("product_id") %>
Question by:kengkit
    LVL 9

    Expert Comment


    Author Comment

    i got the following error:

    Error Creating Control - GridView
    Databinding expressions are only supported on objects that have a DataBinding vent. System.Web.UI.WebControls.HyperLinkField does not have a DataBinding event.
    <asp:BoundField DataField="code" HeaderText="Product Code" />
    NavigateUrl='<%# String.Concat("product_spec.aspx?action=edit&ID=", Eval("product_ID")) %>' ShowHeader="False" Text="View/Edit" />

    Open in new window

    LVL 9

    Accepted Solution

    I'm sorry, my pointer really did fit to hyperlinkfiels. try following instead:

    <asp:BoundField DataField="code" HeaderText="Product Code" />
    <asp:HyperLinkField DataNavigateUrlFields="product_ID" DataNavigateUrlFormatString="product_spec.aspx?action=edit&ID={0}" ShowHeader="False" Text="View/Edit" />

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now