Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am trying to configure a Data View web part in SP Designer 2010. I am connecting it to a list called Data Returns.

Data Returns includes a mixture of Fields, some text, some choice, some lookup.

Whenever I insert a lookup field into the DVWP the data displays as raw html like this:

<a onclick="OpenPopUpPage('http://****/departments/ITG/IRP/DPAR/_layouts/listform.aspx?PageType=4&ListId={A655B962-2383-44F4-8FFA-BB2BD72D8***}&ID=10&RootFolder=*', RefreshPage); return false;" href="http://****/departments/ITG/IRP/DPAR/_layouts/listform.aspx?PageType=4&ListId={A655B962-2383-44F4-8FFA-BB2BD72D****}&ID=10&RootFolder=*">P309 - TOM1.</a>

All that should be displayed is "P309 - TOM1". Is this a known issue with Lookups and DVWP? Is their an easy way of coverting this to the actual data value?

share|improve this question
    
Stephen's solution helped a lot. Thanks –  user4774 Sep 14 '11 at 6:52
add comment

1 Answer 1

You'll need to do some substring functions to get the data. In this case, you'd do something like this, you might need to encode the special characters like " < >:

<xsl:value-of select="substring-after(substring-before(@YourColumn, '</a>'), 'RootFolder=*">')" />

This is also the case with fields like Person/group fields if you want plain text values and not hyperlinks. You can check out some of the XSLT telpates thaat are posted on spxslt.codeplex.com. This might make a good addition to the templates.

share|improve this answer
    
Thanks PirateEric. I found another solution by selecting the cell and clicking "format as label". However, if I was to implement your suggestion, would I need to switch to code view to enter the xsl above? –  Stephen May 23 '11 at 16:41
    
Yep, that would be for the code view. You might have to tinker with it slightly, it's purely untested code. Typically, you have to escape the special characters. –  PirateEric May 23 '11 at 17:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.