Click to See Complete Forum and Search --> : Loop controls


anderzzo
July 18th, 2003, 01:49 AM
I have a aspx page containing an asp:panel called "Step3", in this panel there's 4 tables called "contact", "admin", "tech" and "billing" all runs as server controls.
These tables are filled with "HtmlControls.HtmlInputText"(also running as server controls)
I try to loop all HtmlControls inside this panel with this code:

foreach(Control ctrl in Step3.Controls)
{
Response.Write(ctrl.ID + " " + ctrl.GetType().ToString() + "<br>");
}


But all I get in output is

System.Web.UI.LiteralControl
contact System.Web.UI.HtmlControls.HtmlTable
System.Web.UI.ResourceBasedLiteralControl
admin System.Web.UI.HtmlControls.HtmlTable
System.Web.UI.LiteralControl
billing System.Web.UI.HtmlControls.HtmlTable
System.Web.UI.LiteralControl
tech System.Web.UI.HtmlControls.HtmlTable
System.Web.UI.ResourceBasedLiteralControl
P3Next System.Web.UI.WebControls.Button
System.Web.UI.LiteralControl

If I put a HtmlControl outside a table it shows up on the list. I've also tried to replace "Step3.Controls" with "admin.Controls" but then I only get the output:
System.Web.UI.HtmlControls.HtmlTableRow

Can anyone help me solve this problem? What do I need to do to loop all controls?

parabiz
August 7th, 2003, 08:09 AM
Try this and will surely solve your problem
in your loop do like this

YourPanel.Controls.Add(ChildControlNameHere);

:)