.NET c#:  Add link to BoundField

Posted on 2009-02-23
Last Modified: 2013-12-17
Hi All,

I have a BoundField that outputs an ID.  I want this to be a hyperlink.



Many thanks


         <asp:BoundField DataField="ID" HeaderText="ID"/>


Open in new window

Question by:detox1978
    LVL 8

    Accepted Solution

    Just use a hyperlinkfield. And use the DataNavigationUrlFormatString property.

    Set it to the url of the file plus the text "&{0}". This will replace {0} with the value of the field.

    e.g. DataNavigateUrlFormatString= "/default.aspx&{0}"
        <asp:HyperLinkField HeaderText="ID" DataTextField="ID" DataNavigateUrlFields="ID" DataNavigateUrlFormatString= "/default.aspx&{0}" />

    Open in new window

    LVL 2

    Author Comment

    Thanks that worked a treat....
    LVL 8

    Expert Comment

    that's no problem. anytime.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    754 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

    20 Experts available now in Live!

    Get 1:1 Help Now