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;
        }
Comments (2) Trackbacks (0)
  1. nice algorithm to explain a recursive method, I always feel dizzy with recursive staff

  2. Too bad, seems that is the only way can locate the sub controls in this DataPager .Net control.


Leave a comment


No trackbacks yet.