Binding a Repeater control to an ArrayList of objects

  • Thread starter Thread starter Abhishek Srivastava
  • Start date Start date
A

Abhishek Srivastava

Hello All,

What is the syntax to bind a Repeater control to an Array of objects
I have an array of objects of type Person

Person
{
public int id;
public string name;
}

I tried this one but it didn't work.

<asp:Repeater Id='rep1' runat='server'>
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "id") %> <br/>
</ItemTemplate>
</asp:Repeater>

Thanks for your help in advance.

regards,
Abhishek.
 
Expose the members you want to Eval as public properties of your
objects, not as fields.

i.e.

public string Name
{
get { ... }
}

HTH,
 
Back
Top