Author: drpcken | Posted on: 7/3/2008 5:54:50 PM | Views : 330

I have about 5 drop downlists on my webform that are all filled with the same information from a database.  Instead of going through one at a time at runtime and populating these dropdownlists, is there anyway to use a controlcollection to fill these in a loop?  Let me explain a bit more:
 They all have the same naming scheme except for the last character which is a number (ie  DropDownList1, DropDownList2, etc...)  I want to iterate through them and attach a datasource like this:

for (int i = 0, i <5, i++)

{
DropDownList(i).DataSource = ds;
DropDownList(i).DataTextValue("Value");

}   Is there anyway to do this with a ControlCollection or sometype of array?  I've been messing with ControlCollection but haven't had any luck.
Thanks!
 
...

Go to the complete details ...