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?


2 Answers 2


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.

  • 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, 2011 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. May 23, 2011 at 17:14
  • @Stephen - I was excited to find such a simple solution, but when I format as label, I'm still getting a hyperlink. would you be willing to share the code of your label-formatted field so I can compare with mine? (assuming you have still have access to it..)
    – Pete
    Oct 22, 2014 at 18:31
  • @PirateEric - I found a solution even I could understand on your linked codeplex resource via the StripHTML template. Thanks much for sharing!
    – Pete
    Oct 22, 2014 at 19:30

To render field without escaping you can use following attribute:

<xsl:value-of disable-output-escaping="yes" select="@MultiLookupTest_x003a_TestField"/>

From MSDN:


Default is "no". If the value is "yes", a text node generated by instantiating the element will be output without any escaping.

Consider disable-output-escaping="yes" an advanced feature, to be used only when the potential dangers are understood.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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