Toars I will smile to the world ^o^

24Sep/092

How to access the sub controls in the PagerTemplate in DataPager .NET control

At least for me, I can not use MyDataPage.FindControl("LblPage") to find my LblPage control in the PagerTemplate.

I have to use an recursive way to locate it.

        public static Control FindControlRecursive(Control container, string id)
        {
            if (container.ID == id)
                return container;

            foreach (Control control in container.Controls)
            {
                Control foundControl = FindControlRecursive(control, id);

                if (foundControl != null)
                    return foundControl;
            }

            return null;
        }
Tagged as: 2 Comments