Link to home
Start Free TrialLog in
Avatar of zozig
zozigFlag for United States of America

asked on

Nested Repeater with an ArrayList

Hello all,

Can anyone tell me if it is possible to have a nested repeater that utilizes an ArrayList or a multiDimensional ArrayList as its DataSource?? If so, could you share some code that would demonstrate how to bind the childview to the ArrayList.  
ASKER CERTIFIED SOLUTION
Avatar of esteban_felipe
esteban_felipe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of _TAD_
_TAD_




This doesn't really answer your question, but I think what you are asking is possible.  You just have to cast the object as the right type in order for it work properly.


Using a nested arraylist is pretty easy, you just have to remember that an arraylist returns an object so you have to 'cast' you inner list as an arraylist object and then pull the data from there.  


Nested ArrayLists

ArrayList listOuter = new ArrayList();
ArrayList listInner;

for(int outer=0;outer<10;outer++)
{
   listInner = new ArrayList();

   for(int inner=0;inner<5; inner++)    
        listInner[inner] = "item: " + inner;

   listOuter[outer] = listInner;
}



for(int i=0;i<10;i++)
   for(int j=0;j<5;j++)
      Console.WriteLine(   ((ArrayList)listOuter[i])[j].ToString()  );



Now if you want to set the inner arraylist as a datasource, I think you can do that by making sure your object is cast properly and that you are only pointing to ONE collection (not a collection of collections).
Avatar of zozig

ASKER

Thanks for the quick reply,

This example is awesome, it demonstrates exactly what I need to know. Thanks.