如果 Sharepoint 中的数据视图 Web 部件没有数据,如何显示默认文本?

发布于 2024-07-10 22:48:19 字数 98 浏览 4 评论 0原文

我正在尝试使用 Sharepoint 中的数据视图 Web 部件。 网络上有许多与填充数据相关的文章。 我的问题是,如果数据源为空怎么办? 在这种情况下有没有办法显示默认消息?

I am trying to use the Data View Web Part in Sharepoint. There are many articles on the web related to populating it with data. My question is, what if the data source is empty? Is there a way to display a default message in this scenario?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

晚雾 2024-07-17 22:48:19

您可以在 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>

You can do this in the XSL stylesheet, which is what SharePoint Designer does when you set the text to display if 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>
中性美 2024-07-17 22:48:19

转到 DataView 属性,在底部的常规选项卡下有一个字段,您可以在其中键入要在显示 n 数据时显示的消息。

Go to the DataView properties, under the General tab at the bottom there is a field where you can type the message that you want to display if there n data displayed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文