Repeater control with Arraylist

  • Thread starter Thread starter fix
  • Start date Start date
F

fix

Hi all,

I am trying to bind some data I got in an ArrayList, how is that possible? I
see no example in the help.
The code behind to bind is simple:

rptItems.DataSource = alist
rptItems.DataBind()

But I just don't know what to write in the ItemTemplate in the HTML.

Please help.
fix.
 
Pretty much the same as you'd write with any other object you bind
against. E.g.:

<ItemTemplate>
Bla: <%# ((TypeOfObject)Container.DataItem).Whatever %> or <%#
DataBinder.Eval(Container.DataItem, "Whatever") %>
</ItemTemplate>
 
The things I insert to the Arraylist is not objects, it is some strings or
integers. So it doesn't have any "whatever" property. What do I do?
Thanks.
fix.
 
Container.DataItem just represents an item in the data source. In your
case you can just do <%# Container.DataItem %> instead.
 
Back
Top