How to make multi-dimensional, untyped array?
Posted on 2008-06-24
I would like to store a key with 4 associated controls to it so I can make changes to several controls within a loop. For example, this is what I'm trying to store into an array:
1.) header, (Literal)headerLiteral, (TextBox)headerTextbox, (DropDown)headerDropdown, (CheckBox)headerCheckbox;
2.) content, (Literal)contentLiteral, (TextBox)contentTextbox, (DropDown)contentDropdown, (CheckBox)contentCheckbox;
3.) footer, (Literal)footerLiteral, (TextBox)footerTextbox, (DropDown)footerDropdown, (CheckBox)footerCheckbox;
This way, I can do something like:
for (int i = 0; i < someArray.Count; i++)
(Literal)someArray[i].Text = someArray[i] + " Section";
(TextBox)someArray[i].Text = String.Empty;
(DropDown)someArray[i].SelectedIndex = 0;
(CheckBox)someArray[i].Checked = false;
Also, it might be too much to ask, but I also would like to reference the array element by the associative key name, like: (Literal)someArray["footer"].Text = "Footer Section";
Can anybody help me with choosing the right C# array/collection for this type of usage?