Overview
Apart from Paging Support, one of the features that Repeater lacks is the "Empty Data Template" that will be shown when there is no result too display. MONA blogged a very simple method to implement a "Empty Data Template" for Repeater, and this implementation does not include writing anything in code behind.
Reference
Repeater with Empty Data Template
Code Snippet
I modified the code from MONA's blog a bit, by changing the "Label" to "Panel" inside the Footer Template. In this way we can treat the "Panel" as "Empty Data Template".
<asp:Repeater ID="RptrContacts" runat="server">
<ItemTemplate>
<!-- Add your Item Template Here -->
</ItemTemplate>
<FooterTemplate>
<asp:Panel ID="pnlEmpty" runat="server" Visible='<%#bool.Parse((RptrContacts.Items.Count==0).ToString())%>'>
<asp:Label ID="Label1" Text="no result" runat="server" />
</asp:Panel>
</FooterTemplate>
</asp:Repeater>
沒有留言:
發佈留言