Oct 28, 2009

Handling Empty Data in an ASP.NET Repeater control


    
 In the FooterTemplate, add a Label with some empty data text and set its visible property to false.

C#
    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (Repeater1.Items.Count < 1)
        {
            if (e.Item.ItemType == ListItemType.Footer)
            {
                Label lblFooter = (Label)e.Item.FindControl("lblEmptyData");
                lblFooter.Visible = true;
            }
        }
}

No comments:

Post a Comment