您的位置:首页 > 其它

Repeater在无数据记录时显示类似GridView的无信息内容

2009-11-12 18:23 706 查看
方法就是在FooterTemplate加个Label并根据repeater.Items.Count判断是否有记录。关键代码如下:
<FooterTemplate>
<asp:Label ID="lblEmpty" Text="无记录.." runat="server"  Visible='<%#bool.Parse((rptRecord.Items.Count==0).ToString())%>'></asp:Label>
</FooterTemplate>

示例代码:
<table class="r_line" cellpadding="3" cellspacing="1" width="100%">
<tr class="r_title">
<td>编号</td>
</tr>
<asp:Repeater ID="rptRecord" runat="server">
<ItemTemplate>
<tr style='background-color:<%#(Container.ItemIndex%2==0)?"#fff":"#eee"%>'>
<td><a href='Detail.aspx?PID=<%=Request.QueryString["PID"] %>&did=<%#Eval("PID") %>'><%#Eval("PID") %></a></td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr class="r_bg">
<td>
<asp:Label ID="lblEmpty" Text="无记录.." runat="server"  Visible='<%#bool.Parse((rptRecord.Items.Count==0).ToString())%>'></asp:Label>
</td>
</tr>
</FooterTemplate>
</asp:Repeater>
</table>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: