strickdd
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="For mURL" DataNavigateUrlFormatStrin g="http://{0}"
HeaderText="Form URL" SortExpression="FormURL" Target="_blank" DataTextField="FormURL" />
<asp:HyperLinkField DataNavigateUrlFields="For
HeaderText="Form URL" SortExpression="FormURL" Target="_blank" DataTextField="FormURL" />
<asp:Hyperlink runat="server" Text='View Form' NavigateUrl='<%#"http://" & Server.UrlEncode(Container .DataItem( "fieldname "))%>' ID="Hyperlink1" Target="_new" Enabled=True/>
ASKER
That doesn't work in the gridview. It says:
Error 1 System.Web.UI.WebControls. DataContro lFieldColl ection must have items of type 'System.Web.UI.WebControls .DataContr olField'. 'asp:Hyperlink' is of type 'System.Web.UI.WebControls .HyperLink '. C:\Inetpub\wwwroot\Science Fair\Admin \SpecialCo nditions.a spx 19
Error 1 System.Web.UI.WebControls.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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".
FormURL = "www.somewhere.com/page.pdf"
I need this value from the DB to be the location of the link that says "View".