开发者

Application doesnt display my Editor/Display Templates?

I have two display templates in the folder Views/Shared/DisplayTemplates called:

ShowMCQViewModel

ShowMatrixViewModel

@foreach (var item in Model.Data)
    {
        <p>@M开发者_如何学Goodel.Data.Count()</p>
        <p>@item.GetType()</p>
        Html.DisplayFor(x => item);
    }

The Count() method returns: 2 and GetType() returns: MvcApplication3.Models.ViewModels.Question.ShowMCQViewModel

But the View does not display anything from the Display Template..

I did the exact same thing in another Web Application, the models were just in the Models folder, and it worked fine.

Do i need to set up paths or something?

Thanks


Try with this:

@foreach (var item in Model)
{
    <p>@Model.Data.Count()</p>
    <p>@item.GetType()</p>
    Html.DisplayFor(x => item.Data);
}

You will loop through the Model and pick each Data item that will be displayed using ShowMCQViewModel template

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜