Recursive Function to find the Control in the Parent Controls
By James H
Some times we need to find the child control in the parent control's using the loop structure.I have faced this issue many times and got a unique solution to find the child control in the Parent Controls.
The recursive function in order to loop the Parent Control's is given below
private Control FindControlRecursive(Control root, string id)
{
if (root.ID == id)
{
return root;
}
foreach (Control c in root.Controls)
{
Control t = FindControlRecursive(c, id);
if (t != null)
{
return t;
}
}
return null;
}
Recursive Function to find the Control in the Parent Controls (606 Views)