Here's how I pull a field from my object: <%# DataBinder.Eval(Container.DataItem, "Name") %>
However, how do I pull a field if it's in a subclass (Customer.ContactInfo.Name)?
Here's how I pull a field from my object: <%# DataBinder.Eval(Container.DataItem, "Name") %>
However, how do I pull a field if it's in a subclass (Customer.ContactInfo.Name)?
If you know that the DataItem is a certain type (let's say you know it's a CustomerInfo type), you can do this:
<%# ((CustomerInfo) Container.DataItem).ContactInfo.Name %>
As a bonus, it's somewhat quicker than using DataBinder.Eval, because you avoid all the overhead of reflection.
If the repeater is being bound to a collection of Customer objects then to grab the name from the contact info: <%# DataBinder.Eval(Container.DataItem, "ContactInfo.Name") %>