渲染空中继器 [英] Render empty repeater

查看:97
本文介绍了渲染空中继器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Repeater 不包含任何项目时,即使 HeaderTemplate FooterTemplate ,也不会完全以HTML呈现.即使它为空,我也需要在客户端对其进行操作.

When Repeater contains no items it's not get rendered in HTML at all, even HeaderTemplate or FooterTemplate. I need to manipulate it on client-side even if it's empty.

有什么方法可以始终以HTML呈现Repeater吗?

Is there any way to always render Repeater in HTML?

推荐答案

< FooterTemplate> 中,添加带有一些空数据文本的Label并将其可见属性设置为false.

In the <FooterTemplate>, add a Label with some empty data text and set its visible property to false.

<FooterTemplate>
<table>
 <tr>
 <td>
 <asp:Label ID="lblEmptyData"
        Text="No Data To Display" runat="server" Visible="false">
 </asp:Label>
 </td>
 </tr>
 </table>           
 </FooterTemplate>

现在在绑定转发器时检查数据,如果没有行返回,则使标签可见,否则不执行任何操作.

Now check the the data while binding repeater, if no rows return then make label visible otherwise no action.

更多详细信息此处.

这篇关于渲染空中继器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆