<newbie> HyperLinkField

J

Jeff

Hi

asp.net 2.0

I'm trying to implement a HyperLinkField into my GridView.. The
SqlDataSource returns a field which is paths to files (each row in the
GridView should have link to a file).

I've specified DataTextFields and DataNavigationUrlFields with the column
name which holds the path to the document. But the GridView doesn't create a
link, it just displays it as text...

what I do wrong here?
 
G

Guest

Hi

asp.net 2.0

I'm trying to implement a HyperLinkField into my GridView.. The
SqlDataSource returns a field which is paths to files (each row in the
GridView should have link to a file).

I've specified DataTextFields and DataNavigationUrlFields with the column
name which holds the path to the document. But the GridView doesn't create a
link, it just displays it as text...

what I do wrong here?

Hi Jeff,

what is the code of hyperlinkfield?

Check the following links, maybe you will see the difference
http://authors.aspalliance.com/aspxtreme/webforms/controls/addinghyperlinkfieldstogridview.aspx
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hyperlinkfield.aspx

Hope this helps
 
J

Jeff

what is the code of hyperlinkfield?
- it is like this: c:\website1\Documents\test.txt

could it be that I'm missing http... in the beginning of the code?
 
G

Guest

what is the code of hyperlinkfield?
- it is like this: c:\website1\Documents\test.txt

could it be that I'm missing http... in the beginning of the code?

Sorry I mean this code

<asp:hyperlinkfield text="Details..."
navigateurl="~\details.aspx"
headertext="Order Details"
target="_blank" />

How does it look like in your page?
 
J

Jeff

<asp:hyperlinkfield text="Details..."
navigateurl="~\details.aspx"
headertext="Order Details"
target="_blank" />

creates a clickable hyperlink which opens the details.aspx webpage in my
project.

But this markup doesn't create a clickable hyperlink:
<asp:hyperlinkfield DataTextField="sti" DataNavigateUrlFields="sti"
Target="_blank" />

"sti" have the value "c:\website1\Documents\test.txt"

any suggestions?
 
G

Guest

"sti" have the value "c:\website1\Documents\test.txt"

This path is local. To make the document available for all your
visitors you should change the path to "/Documents/test.txt" if "c:
\website1" is the root directory of your website.
 
A

Andy B

"sti" have the value "c:\website1\Documents\test.txt"
This path is local. To make the document available for all your visitors
you should change the path to "/Documents/test.txt" if "c:\website1" is the
root directory of
your website.

Did you consider turning the HyperLinkField into a TemplateField? This gives
better flexability in the control of what happens with your link. I almost
never use HyperLinkFields for that reason. It also lets me do custom code
behind the link clicks and stuff (if you need to do that). By chance you
want to use a TemplateField and put a HyperLink control there instead, then
the HyperLinks should look like this:

<asp:HyperLink id="link" NavigateUrl='<%# Eval("ski") %>' ...
</asp:HyperLink>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top