Link to home
Create AccountLog in
Avatar of jgerbitz
jgerbitzFlag for Canada

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
Avatar of p_davis
p_davis

is there a page.controls ?
ASKER CERTIFIED SOLUTION
Avatar of p_davis
p_davis

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of jgerbitz

ASKER

Thanks, that's the ticket.