Link to home
Start Free TrialLog in
Avatar of strickdd
strickddFlag for United States of America

asked on

Gridview HyperLinkField

I have a URL I'm saving to a DB and want to display as a clickable link on a Gridview. I want the text of the link to be "View Form" and the URL to be the value pulled back from the DB. Anyone know how to do this? Here is what I got, but is not working:

<asp:HyperLinkField DataNavigateUrlFields="FormURL" DataNavigateUrlFormatString="http://{0}"
                            HeaderText="Form URL" SortExpression="FormURL" Target="_blank" DataTextField="FormURL" />
Avatar of Pra4444
Pra4444
Flag of United States of America image

<asp:Hyperlink runat="server" Text='View Form' NavigateUrl='<%#"http://" & Server.UrlEncode(Container.DataItem("fieldname"))%>' ID="Hyperlink1" Target="_new" Enabled=True/>
Avatar of strickdd

ASKER

That doesn't work in the gridview. It says:

Error      1      System.Web.UI.WebControls.DataControlFieldCollection must have items of type 'System.Web.UI.WebControls.DataControlField'. 'asp:Hyperlink' is of type 'System.Web.UI.WebControls.HyperLink'.      C:\Inetpub\wwwroot\ScienceFair\Admin\SpecialConditions.aspx      19      
ASKER CERTIFIED SOLUTION
Avatar of Pra4444
Pra4444
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That's closer to what I need. However, in the DB i'm storing something like:

FormURL = "www.somewhere.com/page.pdf"

I need this value from the DB to be the location of the link that says "View".