How do I display the default text when the Data View Web Part in Sharepoint has no data?
I am trying to use the Data View Web Part in Sharepoint. There are many articles on the Internet related to filling in data. My question is, what if the data source is empty? Is there a way to show the default message in this scenario?
+1
leroy jenkins
source
to share
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
BjΓΈrn Furuknap
source
to share
Go to the properties of the DataView, on the General tab, a field will appear at the bottom where you can enter the message you want to display if n data is displayed.
+1
Reuben
source
to share