如果Sharepoint中的数据视图Web部件没有数据,如何显示默认文本?
我正在尝试在Sharepoint中使用数据视图Web部件。网上有很多文章都是关于用数据填充的。我的问题是,如果数据源是空的怎么办?在这种情况下是否有显示默认消息的方法?您可以在XSL样式表中执行此操作,这是SharePoint Designer在设置文本以显示数据源为空时所做的操作如果Sharepoint中的数据视图Web部件没有数据,如何显示默认文本?,sharepoint,web-parts,dataview,Sharepoint,Web Parts,Dataview,我正在尝试在Sharepoint中使用数据视图Web部件。网上有很多文章都是关于用数据填充的。我的问题是,如果数据源是空的怎么办?在这种情况下是否有显示默认消息的方法?您可以在XSL样式表中执行此操作,这是SharePoint Designer在设置文本以显示数据源为空时所做的操作 <xsl:variable name="dvt_IsEmpty" select="$dvt_RowCount = 0" /> <xsl:choose> <
<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>
可以在XSL样式表中执行此操作,这是SharePoint Designer在将文本设置为在数据源为空时显示时所做的操作
<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>
转到DataView属性,在底部的常规选项卡下有一个字段,在该字段中,如果显示了n个数据,您可以键入要显示的消息。转到DataView属性,在底部的常规选项卡下有一个字段,您可以键入要显示的消息(如果显示了n个数据)