Tuesday 21 June 2011

Asp.Net: Handle empty list in Repeater



Repeater in Asp.Net Webforms is a commonly used user control for presenting lists data. It's quite handy but it lacks support for empty lists.

Below is a simple workaround:









<asp:Label ID="lblEmptyList"
runat="server"
Text="The list is empty"
Visible='<%#bool.Parse((RptrMyList.Items.Count==0).ToString())%>'>
</asp:Label>

No comments: