Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > <newbie> HyperLinkField

Reply
Thread Tools

<newbie> HyperLinkField

 
 
Jeff
Guest
Posts: n/a
 
      11-20-2008
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?


 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      11-20-2008
On Nov 20, 8:31*am, "Jeff" <(E-Mail Removed)> wrote:
> 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/aspxt...ogridview.aspx
http://msdn.microsoft.com/en-us/libr...linkfield.aspx

Hope this helps
 
Reply With Quote
 
 
 
 
Jeff
Guest
Posts: n/a
 
      11-20-2008
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?


 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      11-20-2008
On Nov 20, 9:09*am, "Jeff" <(E-Mail Removed)> wrote:
> 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?
 
Reply With Quote
 
Jeff
Guest
Posts: n/a
 
      11-20-2008
<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?


 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      11-20-2008
On Nov 20, 10:24*am, "Jeff" <(E-Mail Removed)> wrote:
> "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.
 
Reply With Quote
 
Andy B
Guest
Posts: n/a
 
      11-20-2008
> "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>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET 2.0 HyperLinkField / DataNavigateUrlFields =?Utf-8?B?Y2dhbWJpbm8=?= ASP .Net 0 01-11-2006 04:27 PM
HyperLinkField : DataNavigateUrlFormatString question... Renato ASP .Net 0 01-06-2006 10:35 AM
HyperLinkField =?Utf-8?B?TWljaGFlbFk=?= ASP .Net 1 11-17-2005 03:59 PM
Adding a HyperLinkField to a DatGrid John Smith ASP .Net 0 06-17-2005 05:06 PM
HyperLinkField Help Bruno Alexandre ASP .Net 1 12-06-2004 02:01 PM



Advertisments