方法就是在FooterTemplate加个Label并根据repeater.Items.Count判断是否有记录。关键代码如下:
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><FooterTemplate>
<asp:Label ID="lblEmpty" Text="无记录.." runat="server" Visible='<%#bool.Parse((rptRecord.Items.Count==0).ToString())%>'>asp:Label>
FooterTemplate>
示例代码:
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><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>
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/12639172/viewspace-617168/
,如需转载,请注明出处,否则将追究法律责任。