Solved

How to make multi-dimensional, untyped array?

Posted on 2008-06-24
1
557 Views
Last Modified: 2013-11-07
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][1].Text = someArray[i][0] + " Section";
    (TextBox)someArray[i][2].Text = String.Empty;
    (DropDown)someArray[i][3].SelectedIndex = 0;
    (CheckBox)someArray[i][4].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"][1].Text = "Footer Section";

Can anybody help me with choosing the right C# array/collection for this type of usage?
0
Comment
Question by:bemara57
1 Comment
 
LVL 7

Accepted Solution

by:
nsanga earned 500 total points
Comment Utility
if the sub items in the array ( i.e. controls ) are predefined or known earlier you can do this...

1) define a class with the required types (header, Literal, TextBox,DropDown,CheckBox)
2) for each row create an object of above class type and set the members
3) add the above created objects to a hashtable or other collection dictionary typed collection with required keys....

It is always better to program things in systematic manner with required userdefined types.......

let me know if this is not you are looking for....
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now