Solved

How to make multi-dimensional, untyped array?

Posted on 2008-06-24
1
579 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…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

730 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