Unable to display this Web Part. SharePoint 2010 Data View Web Part issue.


On our intranet, we have been constantly getting the following errors on pages that contains a Data View Web Part. Although I said constantly, it doesn’t mean that the error shows on a page all the time. It meant that a page sometimes works sometimes doesn’t. But if it doesn’t, it will show that error message. The inconsistant of the error makes it more difficult to debug and the log file wasn’t helpful either.

Data View Web Part Error

After searching online, a few people has had the same problem. Someone said it had something to do with a SharePoint Update and suggested to install a hotfix, but we didn’t have that update installed so we didn’t want to try the hotfix. Another post mentioned that adding the “AllowPersonalization” property to a web part zone should fix the problem. However, it didn’t say how to add this property.


Open up the root site in SharePoint Designer. From the left Navigation pane, choose Page Layouts. I had a custom Page Layout used by those pages that displays the Data View Web Part, so I opened that page layout. Follow the prompt and check it out. Click the “Advanced Mode” button on the top ribbon. In your code, search for “WebPartPages:WebPartZone” and inside that tag, add AllowPersonalization=”true”.

For example:

<WebPartPages:WebPartZone id="g_9973D18452754B25AAF6B1DBDC75CF6A" runat="server" AllowPersonalization="true" title="Box 1"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>

After editing the page layout, make sure to check in and publish it.


Display the users IP Address in a Data View Web Part

  1. Open up an existing DVWP or create one.
  2. Right click the DVWP and select ‘Common Data View Tasks’ (or click the little arrow that appears on the top right of the DVWP)
  3. Click the ‘Parameters’ link
  4. In the dialog that opens up click the ‘New Parameter’ button.
  5. Provide a name for the parameter (e.g. IPAddress)
  6. In the ‘Parameter Source’ dropdown select ‘Server Variable’
  7. In the ‘Server Variable Name’ text box enter REMOTE_ADDR
  8. Leave the ‘Default Value’ text box empty
  9. Click OK
  10. Now switch to the code view and go to the place where you want the IPAddress to appear and type the following:
<xsl:value-of select="$IPAddress" />

Here’s a list of server variables:





XSLT displays a multi-select column

Thanks to Marc again for this helpful article.

Here is the xsl code:

<xsl:template name=”MultiSelectDisplay”>
<xsl:param name=”MultiSelectValue”/>
<xsl:param name=”MultiSelectSeparator”/>
<xsl:when test=”contains($MultiSelectValue, ‘;’)”>
<xsl:value-of select=”concat(substring-before($MultiSelectValue, ‘;’), $MultiSelectSeparator)” disable-output-escaping=”yes”/>
<xsl:call-template name=”MultiSelectDisplay”>
<xsl:with-param name=”MultiSelectValue” select=”substring-after($MultiSelectValue, ‘;’)”/>
<xsl:with-param name=”MultiSelectSeparator” select=”$MultiSelectSeparator”/>
<xsl:value-of select=”$MultiSelectValue” disable-output-escaping=”yes”/>

Other useful SharePoint xsl templates written by Marc & Co can be found here.

SharePoint calculated column and data view web part issue


I have a list with a column called newsID. newsID is a calculated column based on created date. I set the column as a number type and leave the decimal places to be automatic.

This list also have another calculated column called newsLink. newsLink is calculated based on newsID.

I have a Data View Web Part to display a item from this list. The DVWP has a parameter and filters based on the newsID column.

Once all of these are setup, open the DVWP in browser. Copy one of the list item’s newsID value to the end of that page’s URL.  The item should display fine in the DVWP page.

Edit that item in the list. Refresh the DVWP page. Oops! You see the message “There are no items to show in this view.”



Change the newsID column to have this formula:


Select data type to be Single line of text.

Issue should be fixed.



Show file attachments for SharePoint list items in a Data View Web Part (DVWP)

I needed to display all the attachments of a SharePoint list item in a DVWP. Thanks to Marc’s article for helping me out.

I added the code that Marc provided between a <td> tag. Magically, it worked!


<xsl:text>Attachments: </xsl:text>
<xsl:element name=”SharePoint:AttachmentsField”>
<xsl:attribute name=”runat”>server</xsl:attribute>
<xsl:attribute name=”FieldName”>Attachments</xsl:attribute>
<xsl:attribute name=”ControlMode”>Display</xsl:attribute>
<xsl:attribute name=”Visible”>true</xsl:attribute>
<xsl:attribute name=”ItemId”>
<xsl:value-of select=”@ID”/>

Display list/library data using Data view web part (DVWP)

Add DVWP to web part page

  1. Open the site that contains the list/library that you need in SharePoint Designer.
  2. Navigate to “All Files”. Create a folder which will be used to store web part pages.
  3. Open the folder. Click “Web Part Page” button on the ribbon.
  4. Choose one of the layouts. Enter a name. Notice the file is actually saved to Site Pages folder. So don’t panic if you don’t see it. Go to “Site Pages” from the left Navigation Pane and cut and paste the page to the folder you created in step 2.
  5. Next, we are going to add the DVWP to the web part page. Click on one of the web part zones. Click “Insert” tab from ribbon->Data View->Empty Data View
  6. In the zone, click “click here to select datasource” to select the datasource or list.
  7. From the “Data Source Picker”, select the interested List or Library.
  8. All the available fields of the selected list or library will be listed in the Data Source Details pane on the right side.
  9. Drag the fields that you want to display to the web part.
  10. To add more columns or rows to the DVWP, click the Table tab on the ribbon and select relevant options.
  11. To add a horizontal rule, highlight the cell, the code will be highlighted in code view, enter <hr />. For example, <td colspan=”5″ /><hr/></tr>

Tips: For columns that displays raw html code, add disable-output-escaping=”yes” For example, <xsl:value-of select=”@Comments” disable-output-escaping=”yes”/>

Grouping, Sorting and Paging in DVWP

For grouping and sorting, click the web part and choose Options->Sort & Group in the ribbon.


For paging, click the web part and choose Options->Paging in the ribbon.


Filters and Parameters in DVWP

To filter on a column, simply click Filter.


To use a Query String, there are multiple steps as below.

  1. Click Options->Parameters->New Parameter. Select “Query String” from Parameter Source. Query String Variable is used in the URL, e.g. agdocs/stakeholder.aspx?ParaVar=ParaValue. Give a Default Value if you have one. Then click OK.
  2. Go to Options->Filter. Choose the field that is based on the parameter value.
  3. Save the page and open in browser. Items with Team value of Director & Support will be displayed as it’s the default value. In the URL, type ?Team=Portfolio Team to the end of the URL, items with Team value of Portfolio Team are displayed.

Export Web Part