public static Control FindControlByTagId(Control.ControlCollection collection, int tagId) { foreach (Control ctrl in collection) { if (ctrl.Tag != null) { if (Convert.ToInt32(ctrl.Tag) == tagId) { return ctrl; } } if (ctrl.HasChildren) { object subControl = FindControlByTagId(ctrl.Controls, tagId); if (subControl != null) { return (Control)subControl; } } } return null; }