Friday, March 16, 2012

Looping thru all DDL on a form, checking for value

Using VB ..

Is there a way to loop through all drop down lists on a web form
checking for a specific value (ddlDropDown.SelectedValue) and then,
based on that value, cause a specific label to go visible or not?

Thanks,
Jimrecursivly loop thru all controls checking the type.

aircode:

LoopThruControls(this);

void LoopThruControls(Control ctl)
{
DropDownList ddl = ctl as DropDownList;
if (ddl !=null)
{
// do somthing with selected value
}
foreach (Control child in ctl.Controls)
{
LoopThruControls(child);
}
}

-- bruce (sqlwork.com)

"Jim in Arizona" <tiltowait@.hotmail.comwrote in message
news:O4tn$7YDHHA.4464@.TK2MSFTNGP06.phx.gbl...

Quote:

Originally Posted by

Using VB ..
>
Is there a way to loop through all drop down lists on a web form checking
for a specific value (ddlDropDown.SelectedValue) and then, based on that
value, cause a specific label to go visible or not?
>
Thanks,
Jim

0 comments:

Post a Comment