I have added few controls to a table and added that table to a panel. Now, I want to access those controls(like text boxes, dropdowns etc..) in another method. I am trying as
List<Control> panelControls = (from pControls in _controlsPanel.Controls.OfType<Table>(). OfType<TableRow>().OfType<TableCell>().OfType<Control>()
.Where(ctrl => (ctrl is TextBox || ctrl is DropDownList))
select pControls).ToList();
which is evudently giving me no controls I added to table and eventually to panel.
Should I add each of the control in my table to Panel or is there a better way to retrieve the controls?
Because, I thought, since all the controls are in a table , it seemed redundant to me to add controls again to panel explicitly. However I might be wrong. please clarify.