Repeater:即使数据源为空也显示页脚

发布于 2024-12-05 03:07:45 字数 178 浏览 5 评论 0原文

是否可以始终显示 ASP.NET 中继器的页眉和页脚,无论它是否不包含数据?

我很清楚,想要显示某种信息性消息的人之前已经问过这个问题,但在我的情况下,这一切都是为了向客户端提供填充完全相同的Repeater 使用页脚中的输入字段提供数据。情况可能很相似,但我一直无法弄清楚。谢谢!

Is it possible to always show the header and footer of an ASP.NET repeater, regardless if it contains no data or not?

I am quite aware that this question has been asked before by people wanting to display some kind of informative message, but in my situation, it's all about providing the client with the means to populate the very same Repeater with data using input fields in the footer. The situations might be similar, but I haven't been able to figure it out. Thanks!

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

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

发布评论

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

评论(1

小ぇ时光︴ 2024-12-12 03:07:45

我找到了一篇文章可以帮助您解决此问题,

基本上技巧就在这里:

 protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (Repeater1.Items.Count < 1)
        {
            if (e.Item.ItemType == ListItemType.Footer)
            {
                Label lblFooter = (Label)e.Item.FindControl("lblEmptyData");
                lblFooter.Visible = true;
            }
        }
    }

因此,当没有项目时,您也可以填充页脚...

请参阅此处的完整文章,祝您好运。

处理 ASP.NET Repeater 控件中的空数据

I've found an article that should help you with this,

basically the trick is here:

 protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (Repeater1.Items.Count < 1)
        {
            if (e.Item.ItemType == ListItemType.Footer)
            {
                Label lblFooter = (Label)e.Item.FindControl("lblEmptyData");
                lblFooter.Visible = true;
            }
        }
    }

so you populate the Footer also when there are no items...

see full article here and good luck.

Handling Empty Data in an ASP.NET Repeater control

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