How to find controls in a repeater header or footer

前端 未结 8 2126
离开以前
离开以前 2020-11-28 02:19

I was wondering how one would find the controls in the HeaderTemplate or FooterTemplate of an Asp.Net Repeater control.

I can access them on the ItemDataBound event,

相关标签:
8条回答
  • 2020-11-28 03:20

    The best and clean way to do this is within the Item_Created Event :

     protected void rptSummary_ItemCreated(Object sender, RepeaterItemEventArgs e)
            {
                switch (e.Item.ItemType)
                {
                    case ListItemType.AlternatingItem:
                        break;
                    case ListItemType.EditItem:
                        break;
                    case ListItemType.Footer:
                        e.Item.FindControl(ctrl);
                        break;
                    case ListItemType.Header:
                        break;
                    case ListItemType.Item:
                        break;
                    case ListItemType.Pager:
                        break;
                    case ListItemType.SelectedItem:
                        break;
                    case ListItemType.Separator:
                        break;
                    default:
                        break;
                }
        }
    
    0 讨论(0)
  • 2020-11-28 03:21

    You can take a reference on the control on the ItemCreated event, and then use it later.

    0 讨论(0)
提交回复
热议问题