I use my own extension method, which searches for a control (e.g. a placeholder, for example) recursively to find the control you are looking for by identifier and return it. After that, you can fill in the returned control. Call this in a foreach loop, iterating over your list of controls to populate.
public static class ControlExtensions { /// <summary> /// recursive control search (extension method) /// </summary> public static Control FindControl(this Control control, string Id, ref Control found) { if (control.ID == Id) { found = control; } else { if (control.FindControl(Id) != null) { found = control.FindControl(Id); return found; } else { foreach (Control c in control.Controls) { if (found == null) c.FindControl(Id, ref found); else break; } } } return found; } }
source share