How do I display the default text when the Data View Web Part in Sharepoint has no data?
2 answers
You can do this in an XSL stylesheet, which is what SharePoint Designer does when you set the text to display if the data source is empty.
<xsl:variable name="dvt_IsEmpty" select="$dvt_RowCount = 0" />
<xsl:choose>
<xsl:when test="$dvt_IsEmpty">
<xsl:call-template name="dvt_1.empty" />
</xsl:when>
<xsl:otherwise><!-- Do stuff if not empty --></xsl:otherwise>
<xsl:template name="dvt_1.empty"><!-- Default template from SPD -->
<xsl:variable name="dvt_ViewEmptyText">There are no items to show in this view.</xsl:variable>
<table border="0" width="100%">
<tr>
<td class="ms-vb">
<xsl:value-of select="$dvt_ViewEmptyText" />
</td>
</tr>
</table>
</xsl:template>
+3
source to share