How to find controls in a repeater header or footer

前端 未结 8 2140
离开以前
离开以前 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:01

    Find control into Repeater (Header, Item, Footer)

    public static class FindControlInRepeater
    {
        public static Control FindControl(this Repeater repeater, string controlName)
        {
            for (int i = 0; i < repeater.Controls.Count; i++)
                if (repeater.Controls[i].Controls[0].FindControl(controlName) != null)
                    return repeater.Controls[i].Controls[0].FindControl(controlName);
            return null;
        }
    }
    

提交回复
热议问题