FindParent

public static T FindParent<T>(this Control target) where T : Control
{
    if (target.Parent == null)
    {
        return null;
    }

    var parent = target.Parent as T;
    if (parent != null)
    {
        return parent;
    }

    return target.Parent.FindParent<T>();
}
Example:
someControl.FindParent<RepeaterItem>().UniqueID;

Description

A simple type safe method to find a parent control

Details

Double click on the code to select all.

 

;