How can I create a custom Repeater that displays Header, Footer based on properties?

后端 未结 5 1581
长情又很酷
长情又很酷 2021-02-09 07:19

I want to create a Repeater that displays the header/footer based on properties, only if the DataSource is empty.

public class Repeater : System.Web         


        
5条回答
  •  暖寄归人
    2021-02-09 07:42

    If you want to do this with just a repeater you can do this:

        
        
            
                HEADER STUFF
            
        
        
            ITEM STUFF
        
        
            
                FOOTER STUFF
            
        
    
    

    and then in your code behind

        protected void ShowHideHeaderFooter(object sender, RepeaterItemEventArgs e)
        {
            if(e.Item.ItemType == ListItemType.Header && theDataSource.Count == 0 && !ShowHeaderOnEmpty)
            {
                e.Item.FindControl("PlaceHolderHeader").Visible = false;
            }
            ...
        }
    

提交回复
热议问题