Search code examples
asp.netrepeaterasprepeater

How can I hide the entire repeater when its empty from html tag


How can I hide the entire Repeater when the repeater is empty (have no data)

without using code behind?


Solution

  • you can add to the repeater's attributes this code, keep in mind you have to change 'RepeaterName'to the current repeater:

    Visible='<%# RepeaterName.Items.Count != 0 %>
    

    Example of how the start tag of a repeater will be:

    <asp:Repeater ID="RepeaterName" runat="server" Visible='<%# RepeaterName.Items.Count != 0 %>'>
    

    ** Sorry if this is a duplicate, I have been trying to find the best answer for a long time, and I just found it.