Solved

How to make multi-dimensional, untyped array?

Posted on 2008-06-24
1
588 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 7

Accepted Solution

by:
nsanga earned 500 total points
ID: 21856962
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

724 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