Working with groups of user controls...

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Jim (Jim_at_discussions.microsoft.com)
Date: 11/26/04


Date: Fri, 26 Nov 2004 13:29:02 -0800

I have nineteen user controls that are named "user_" concatenated with
(0-18). How can I loop through and set the visibility property to false for
each one. I tried something like:

protected alss.controls.something user_0;
protected alss.controls.something user_1;
protected alss.controls.something user_2;
...

for (Int32 i = 0; i <= 18; i ++) {
UserControl objUser = (UserControl) Page.FindControl ("user_" + i.ToString);
objUser.Visibility = false;
}

Any ideas?