Biniding custom objects to DataRepeater

N

Neven Klofutar

Hi,

How can I bind ArrayList of my object to DataRepeater ?


I have 2 classes:

public class Movie {
private String _Name = "";
private Double _Price = 0;

// getters and setters

public Item() {}
}
public class Items {
private Movie _Movie = null;
private Int16 _Quantity = 1;

// getter and setter
}

How can I use ArrayList of Items as a DataRepeater.DataSource ?
What should I use in DataBinder.Eval ?

<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "Name") %><br>
</ItemTemplate>


thanx, Neven
 
K

Karl Seguin

DataBinder.Eval is a smart cookie. Specify the name of a property (getters)
and you're all set.

Alternatively, you can use:

((Movie)Container.DataItem).Name (ie, cast Container.DataItem to the
individual items in your arraylist)...but I prefer DataBinder.Eval :)

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
 
N

Neven Klofutar

Or you can use

<%# DataBinder.Eval(Container.DataItem, "Movie.Name") %>


Thanx, Neven
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top