asp.net mvc - MVC 3 multiple DisplayFor-Templates -


i'm trying make custom template basket item list. need few different templates, have different ways of displaying item, depending on if it's on webpage or in mail. problem is, when use default name works flawlessly.

@html.displayfor(b => b.items) 

but when try add template name, expection templates needs of list type ienumerable , not basketitem.

@html.displayfor(i => basket.items, "customeritembaselist") 

any ideas mistake is, or why it's not possible appreciated. thanks.

unfortunately that's limitation of templated helpers. if specify template name collection property template no longer applies automatically each item of collection. possible workaround:

@for (int = 0; < model.items.length; i++) {     @html.displayfor(x => x.items[i], "customeritembaselist") } 

Comments