views:

12

answers:

1

I'll use Customer and Addresses as an example rather than explain my real objects.

Say I have a repeater bound to a collection of Customers and one of the properties of Customer is an array of addresses. How do I bind to the addresses property?

I don't even need to display this information I just want to use it in the Repeaters ItemDataBound event. So I tried to bind a hiddenField to the addresses property but all I get for every customer in the hiddenfields value is an empty array of addresses.

I suppose what would be ideal is if I could bind the hiddenfield to a string representing the addresses array. (perhaps in JSON format). How can I do that? Or has anyone got any better suggestions?

A: 
protected void Repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
    Customer c = (Customer)e.Item.DataItem;

    foreach (Address a in c.Addresses)
    {
        //WHEE!
    }
}
matt-dot-net