开发者

ASP.net binding to a property that is an array of custom types

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 bi开发者_StackOverflownd 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?


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

    foreach (Address a in c.Addresses)
    {
        //WHEE!
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜