1,804 articles and 15,030 comments as of Monday, May 30th, 2011

EndUserSharePoint has combined resources with NothingButSharePoint.com. You can now find End User (Mark Miller), Developer (Jeremy Thake) and IT Pro SharePoint content all in one place!

This site is a historical archive and is no longer being updated. Please update your favorites, bookmarks and RSS feeds.

NothingButSharePoint.com
Thursday, May 14, 2009

Data View Web Part, The Basics – Add a Hyperlink

A note from Mark Miller: Laura Rogers is leading a live online workshop this Friday: Getting Started with the Data View Web Part. This article is a warm up to that presentation.

Solution Overview

When a Data View Web Part is added to a page in SharePoint Designer, it is sometimes useful to include links to the content of the list.  In a regular view of a list on your site in the browser, the list’s Title field is a link to open the item.  In a data view web part, this functionality is not automatically included.  Following is a step-by-step process for using SharePoint Designer to add a hyperlink to a field in a Data View Web Part.

Document library:

I’ve already added the document library to the page as a data view web part.

DVWP Links

Notice that all of the names of the documents are just plain text.  We want each of these to be a hyperlink to open that document.  Here’s how to accomplish that:

  1.  Click to select the name of one of the documents in the “Name” column.  Click the little chevron button next to the field.

    DVWP Links
  2. Notice that the field is formatted as “Text”.  Click the drop-down box to change this format to “Hyperlink”.  Click <Yes> to the message.

    DVWP Links
  3. On the “Edit Hyperlink” screen, clear out the Address field at the bottom.  You’ll notice that this automatically clears out the “Text to Display” field at the same time.
  4. Click the Function button to the right of the Address box.  This screen lets us pick which field should be used for the hyperlink’s address. 

    DVWP Links
  5. Click on the URL Path field, and click <OK>
  6. Clear out the “Text to Display” box at the top, and click the function button next to the box.  Pick the “Name (for use in forms)” field, and click <OK>
  7. The Edit Hyperlink screen now looks like this.  Click <OK>

    DVWP Links
  8. Now, when you save the page, and hit the F12 key to preview this page in the browser, each document’s name will have a link to open that document.

For a LIST, as opposed to a library, the only difference is what is entered in the Address box on the Edit Hyperlink screen.  Here’s how to configure the link to a list item:

  1. Clear out the Address box, and type a backslash. /
  2. Click the function button to the right of the box, choose the Path field, and click OK. 
  3. Type the following after the field you just inserted:
    /Dispform.axpx?ID=
  4. Click the function button again to pick a field.  Select the ID field and click OK.
  5. In the Text to Display box, don’t forget to use the function key to pick which field you would like displayed.  I’ll pick the Title field in this example.  Here’s the result:

    DVWP Links
  6. Click <OK>.  Save the page and preview it in the browser to see how it works.

Now, whether you’re working with a library or a list, you can confidently create hyperlink fields.

If you found this helpful, I’d like to see you at my live online workshop this Friday: Getting Started with the Data View Web Part.


Laura RogersAuthor: Laura Rogers, Birmingham, AL

Laura Rogers is a SharePoint Administrator at HealthSouth Corporation in Birmingham, Alabama. She has ten years of experience with Microsoft’s messaging and collaboration systems, including four years in SharePoint implementation, training, and customization.

Laura has been a MCSE since 1999, with her most recent certifications being MCSE 2003 + Messaging, MCTS in MOSS and MCTS in WSS 3.0 Configuration. She also wrote a chapter in the Microsoft Office SharePoint Server 2007 Administrator’s Companion by Bill English.

View all entries in this series: LauraRogers - Data View Web Part Basics»
 

Please Join the Discussion

24 Responses to “Data View Web Part, The Basics – Add a Hyperlink”
  1. Tom Hallstrom says:

    Thanks so much for a clear solution to a frustratingly widespread issue that I’ve been trying to solve.

    Quick Typo Fix: The added line in Step 3 for lists should be changed to:

    /Dispform.aspx?ID=

    It currently reads “.axpx”.

  2. Ryan Scott says:

    Great series of tutorials Laura, thanks for sharing. It has just opened up my eyes as to what can be done with the Data View Web part (I have been battling trying to get content query web parts to read document libraries with pagination).

    I’m off now to learn how to really style it with xsl… Thanks from a SP n00b!

  3. Harry Le says:

    Thanks so much for these helpful tips. However, I noticed the link break when I tried to add a hyperlink to a list item inside a folder. Any help with this issue would much appreciate. Thanks again for sharing your expertise!

  4. Nancy says:

    This is great!

    Will it work for email addresses? I have a list in a DVWP with a column of email addresses.

    I displayed them as hyperlinks, which appears to format correctly (”link-style”) in the data view. BUT – when a user clicks the link to send an email, it doesn’t “behave” right- they get an error page instead of an email interface.

    Is this doable?

  5. Jim Parker says:

    Another great, quick, and easy tip–thanks Laura.

  6. MLB says:

    I am using a forms library as the data source for my dataview web part. I want the form to open in a web browser as it does from the forms library. It opens in the InfoPath client from a data view web part. Is there a way to configure the data view web part to set the properties of the form to open in a web browser? Thanks

  7. Steve Schultz says:

    SharePoint newbie here, struggling for days to create a Title column that links to the fixed Name (document filename) column when told by my internal company expert that it can’t be done. Well, Laura, your post here has saved the day for all my process document owners and our migration to Sharepoint. Our users can now click on the Title to access a document rather than the obscure filenames we use.

    Thanks,
    Steve

    • Steve – Another way to do it is to create a calculated column that points to the file name and does an HTML href wrapper around it to create a clickable title. You’ll have to use Christophe Humbert’s TextToHTML CEWP web part, but that’s just a cut and paste job into a Content Editor Web Part. — Mark

  8. rogueveggie says:

    Great article. However, I’m trying to link to the “Related Documents” (more than one) in a knowledge base without success. Any recommendations? I’m at a stopping point because of this issue.

  9. elfigha says:

    for wich version this article apply ?

  10. Laura,

    Have you considered making an E-book of this series?

    I am just learning my way around Data Web Parts and having a ready reference to go to do would be helpful. Your Articles and screencasts are very informative and helpful. It’d be nice to have ‘em bundled together.

    -Robin

  11. Steve says:

    Really enjoying the series – very clear explanations and very relevant to real world user requests – thanks!

  12. Lynn says:

    Laura – what modifications need to be made when using a Posts list (on a blog site)? the link ends up with extra characters – e.g., https://sitename/Lists/Posts/5_.000/Dispform.axpx?ID=5 instead of https://sitename/Lists/Posts/Dispform.axpx?ID=5 – and I can’t figure out how to get rid of the extra “/5_.000″

    • Lynn says:

      Actually, Laura – I just used an idea from another of your blog posts – http://sharepoint911.com/blogs/laura/Lists/Posts/Post.aspx?ID=46 – to help me figure out a way to modify the hyperlink. In that post you discussed using “concat” to truncate a string. I ended up using {concat(’/',substring-before(@FileRef,Posts),’Posts/Post.aspx?ID=’,@ID)} (substituting “before” for “after” as you used it) and it worked perfectly! Made my day for sure… thanks!

  13. Dave P says:

    Hi,

    I was wondering how I could get the dataview web part title itself to be a link to the datasource, as oppossed to linking each individual item. Is that possible?

    Thanks,
    Dave

  14. CeCe says:

    I can not tell you how insanely thankful I am that you’ve made this so easy to understand. I work in a place where the blind is leading the blind so its completely uplifting to know there are pros like you willing to share with those of us who seek liberation from our SharePoint conundrums. lol
    This site is my new mecca.

  15. David Wallach says:

    Is there an updated article for adding a hyperlink in Designer 2010?

    Thanks in advance,

    DW

  16. Ben says:

    This article doesn’t work with lookup columns. The dataview column I need as hyperlink is a actually a Site lookup column. When using the {@ID} I get local list ID, not the site column ID.
    So, in SPD I type ../../../List/Products/Dispform.aspx?ID={@ID} but I need something else obviously since the ID needs to be the source item ID, not local list.

    Any help???

  17. Beth C. says:

    Laura, thank you for this wonderful, easy to follow post. I am using your instructions to make the list view title a hyperlink to the item and I get a ‘page not found’ message. Funny thing is that the address displayed is correct when I copy the hyperlink to a list item. It is an announcement board. Any advise you can offer would be greatly appreciated.

  18. The URL link works fine.

    But what I would really like to do is display a document library listing (which is working) and have the URL open the file in its respective editing mode (Edit in Microsoft Word, Excel, etc) when the link is clicked. Not opening the file in Read-Only mode, not opening the properties page.

  19. Beth C. says:

    To create a data view Web part for a blog, follow the instructions to configure for a list and change /Dispform.axpx?ID= to /post.axpx?ID=

    Thanks for the awsome post Laura!

  20. David says:

    Unfortunately this doesn’t work, as the link it provides is missing the main name of my website, and just gives the later part of the address, instead of including after the http:// there should be dhsconnect.dhs.gov and then the rest of the address oia/lists/…. With this it just gives the http://oia/lists/….

    This thread is probably stale, but I’m stuck and could use help anyway.

Trackbacks

Check out what others are saying about this post...
  1. [...] Data View Web Part, The Basics – Add a Hyperlink (Article) Original Publication Date: Thursday, May 14, 2009 SharePoint User Level: Power User When a Data View Web Part is added to a page in SharePoint Designer, it is sometimes useful to include links to the content of the list. In a regular view of a list on your site in the browser, the list’s Title field is a link to open the item. 6 Minute Screencast: Data View Web Part – Add a Hyperlink to a Field Original Publication Date: Thursday, May 14, 2009 SharePoint User Level: Power User This screencast is a supplement to Laura Roger’s article, Data View Web Part, The Basics – Add a Hyperlink.  Yeah, I don’t know why my face was green.  Cheap camera? [...]




Notify me of comments to this article:


Speak and you will be heard.

We check comments hourly.
If you want a pic to show with your comment, go get a gravatar!