views:

229

answers:

3

I have an arraylist:

 Dim downloadsarray As New ArrayList
        downloadsarray.Add(iconlink) 
        downloadsarray.Add(imgpath) 
        downloadsarray.Add(filesize) 
        downloadsarray.Add(description) 

Which is the datasource of my repeater:

 DownloadsRepeater.DataSource = downloadsarray
    DownloadsRepeater.DataBind()

Please can you tell me how I output the items in the array to the .aspx page. I usually use (when using sqldatareader as datasource):

    <%#Container.DataItem("1stcolumnnamestring")%>
    <%#Container.DataItem("2ndcolumnnamestring")%>

But this does not work when using the arraylist as datasource.

Thanks.

ps... I know how to use <%#Container.DataItem%> to dump everything but I need to get at the items in the array individually, not have them all ditched out to the page in one go. For example, item 1 contains a link, item 2 contains an image path, item 3 contains a description. I need to have them kick out in the correct order to build the link and icon correctly.

A: 

Try and use Container.DataItem that should get you the individual elements of the array list.

JoshBerke
That gets me all the items in the array (in one go) no?
Phil
No the DataItem will represent the current item in the list as it's being iterated over by the Repeater
JoshBerke
A: 

Try

<%# Eval(Container.DataItem) #%> 
Steve
+2  A: 

In your example, you should be able to do this:

 <%# Container.DataItem.ToString() %> 

Typically, when binding to a repeater, each data item holds the same type of data. In your example, each item is different - one is the link, one is the image path, etc. This is fine if all you want to display are those exact items (though I would then question whether you need a repeater to do the job).

If your intent is to show multiple links, you should create a class for each link and add instance of the class to your ArrayList:

class LinkThing {
  string link;
  string imagePath;
  etc... (do all the usual stuff with properties and constructors)
}

downloadsarray.Add(new LinkThing(link1, path1, size1, desc1));
downloadsarray.Add(new LinkThing(link2, path2, size2, desc2));

and in the aspx page:

 <%# ((LinkThing)Container.DataItem).link %> 
 <%# ((LinkThing)Container.DataItem).path %> 
Ray