<newbie> HyperLinkField

  • Thread starter Thread starter Jeff
  • Start date Start date
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?
 
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
 
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?
 
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?
 
<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?
 
"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.
 
"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>
 
Back
Top