<newbie> HyperLinkField

Discussion in 'ASP .Net' started by Jeff, Nov 20, 2008.

  1. Jeff

    Jeff 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?
     
    Jeff, Nov 20, 2008
    #1
    1. Advertising

  2. On Nov 20, 8:31 am, "Jeff" <> 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/aspxtreme/webforms/controls/addinghyperlinkfieldstogridview.aspx
    http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hyperlinkfield.aspx

    Hope this helps
     
    Alexey Smirnov, Nov 20, 2008
    #2
    1. Advertising

  3. Jeff

    Jeff 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?
     
    Jeff, Nov 20, 2008
    #3
  4. On Nov 20, 9:09 am, "Jeff" <> 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?
     
    Alexey Smirnov, Nov 20, 2008
    #4
  5. Jeff

    Jeff Guest

    <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?
     
    Jeff, Nov 20, 2008
    #5
  6. On Nov 20, 10:24 am, "Jeff" <> 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.
     
    Alexey Smirnov, Nov 20, 2008
    #6
  7. Jeff

    Andy B 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.


    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>
     
    Andy B, Nov 20, 2008
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bruno Alexandre

    HyperLinkField Help

    Bruno Alexandre, Dec 1, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,449
    Michael Tkachev
    Dec 6, 2004
  2. John Smith

    Adding a HyperLinkField to a DatGrid

    John Smith, Jun 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    944
    John Smith
    Jun 17, 2005
  3. =?Utf-8?B?TWljaGFlbFk=?=

    HyperLinkField

    =?Utf-8?B?TWljaGFlbFk=?=, Nov 17, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    4,096
    =?Utf-8?B?SkdvcmRvbg==?=
    Nov 17, 2005
  4. Renato
    Replies:
    0
    Views:
    1,954
    Renato
    Jan 6, 2006
  5. =?Utf-8?B?Y2dhbWJpbm8=?=

    ASP.NET 2.0 HyperLinkField / DataNavigateUrlFields

    =?Utf-8?B?Y2dhbWJpbm8=?=, Jan 11, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    5,783
    =?Utf-8?B?Y2dhbWJpbm8=?=
    Jan 11, 2006
Loading...

Share This Page