How to store items of 3 ListView's in a class

I have 3 ListView's that are populated like this (well this can be anything, listview is just an example):

this is the first list:

LIST1     LIST2     LIST3
A1         
B1
C1

If I click on 'A1', list2 will get some items:

LIST1     LIST2     LIST3
A1         A2
B1         B2
C1         C2
           D2
           E2

Same happens when I click on a item in list2, then list3 will get some items. I click on A2 this time:

LIST1     LIST2     LIST3
A1         A2       A3
B1         B2       B3
C1         C2       
           D2       
           E2

So the idea is, how can I make an object(class) that hodls all the listview datas?

If it was only 2 I am thinking like this:

public class StoreData
{
   public string ListOne {get;set;}
   public List<string> ListTwo = new List<string>();

   public AddToLostTwo(string text)
   {
      ListTwo.Add(text)
   }
}

And I could do in runtime:

foreach(string str in ListOne)
{
   List<StoreData> datas = new List<StoreData>();
   StoreData data = new StoreData();

   data.ListOne = str;

   foreach(string str2 in ListTwo)
   {
      data.AddToListTwo(str2);
   }
}

So my question is, what is the best way to do this in c# for more than 2 list? Note that I want to later print out on paper something like this:

DUMP LISTS
----------
NAME      VALUE      VALUE
A1         A2        A3
                     B3

A1         B2        D3
                     E3

Please let me know if I am not clear enough!

Answers


You wouldn't really need your own class for this. How about using a Dictionary like

Dictionary<string, IList<string>> lists = new Dictionary<string, IList<string>>();

Then you can add new list like

lists.Add("List1");

And add items to that list like

lists["List1"].Add("Item1");

public class StoreData
{
   public string ItemName {get;set;}
   public List<StoreData> ChildList = new List<StoreData>();

   public AddToChilds(StoreData data)
   {
      ChildList.Add(data)
   }
}

From my opinion using this class structure will allow you to have as many levels as you want.


Need Your Help

Why JSON.parse(JSON.stringify()) fails with a simple dictionary?

javascript

Instead of showing me the dictionary this gives an error when parsing the string.

How can I update a website by publishing to a new address, and then forwarding to it?

asp.net html web-applications website

If I want to update my web site without there being a break in its functioning (almost) I thought I might publish the new version to a new folder, and after it has been uploaded - simply "point" to...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.