I would like to know how to make a list of dropdowns in a C # class. I tried like this:
List<DropDownList> _ddlCollection;
for (int i = 0; i < 5; i++)
{
_ddlCollection.Add(new DropDownList());
}
Then I add _ddlCollection to the Asp.NET site as follows:
foreach (DropDownList ddl in _ddlCollection)
{
this.Controls.Add(ddl);
}
But it breaks in the line:
_ddlCollection.Add(new DropDownList());
Can you tell me how to add some DDL to the list?
source
share