October 15, 2007 0

Recursive Goodness – II

By J in Tags:

Find a control within a control recursively:

protected void Control FindControlRecursive(Control Root, string Id)
{
    if (Root.ID == Id)
    return Root;
    foreach (Control Ctl in Root.Controls)
    {
        Control FoundCtl = FindControlRecursive(Ctl, Id);
        if (FoundCtl != null)
        return FoundCtl;
    }
    return null;
}

Tags:

Leave a Reply