I am trying to loop through every control in a panel and clear out all the contents if it is a DropDownList.
Here is what I have :
private void ClearOut()
{
foreach (Control list in MainPanel.Controls)
{
if (list.ToString().Equals("System.Web.UI.WebControls.DropDownList"))
{
//Clear it out here
}
}
}
This code does find every DropDownList, but then I cannot figure out how to clear them out once I get there. I can't use any properties of a DropDownList like selectedindex or items.clear().