jgerbitz
asked on
foreach statement cannot operate on variables of type 'System.Web.UI.Page'
Hi,
I'm trying to execute some code (VS 2005, C#) but am getting this error:
"foreach statement cannot operate on variables of type 'System.Web.UI.Page' because 'System.Web.UI.Page' does not contain a public definition for 'GetEnumerator'"
The code:
foreach (Control cntl in Page)
{
if (cntl is DropDownList)
{
DropDownList ddl;
if ((string)ddl.SelectedValue == "Select Reason")
{
ddl.SelectedValue = (string)"0";
}
}
}
Thanks
I'm trying to execute some code (VS 2005, C#) but am getting this error:
"foreach statement cannot operate on variables of type 'System.Web.UI.Page' because 'System.Web.UI.Page' does not contain a public definition for 'GetEnumerator'"
The code:
foreach (Control cntl in Page)
{
if (cntl is DropDownList)
{
DropDownList ddl;
if ((string)ddl.SelectedValue
{
ddl.SelectedValue = (string)"0";
}
}
}
Thanks
is there a page.controls ?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thanks, that's the ticket.