У меня есть следующая модель:
namespace Storage.Models
{
public class AdminDetail
{
public string PartitionKey { get; set; }
public string RowKey { get; set; }
public string Title { get; set; }
public string Status { get; set; }
public string Type { get; set; }
public string Level { get; set; }
public string Order { get; set; }
public int Row { get; set; }
}
У меня есть следующий код на мой взгляд:
@model IList<AdminDetail>
<table>
<thead>
<tr>
<th>@Html.LabelFor(x => x[0].Order)</th>
<th>@Html.LabelFor(x => x[0].Order)</th>
<th>@Html.LabelFor(x => x[0].Level)</th>
<th>@Html.LabelFor(x => x[0].Title)</th>
<th>@Html.LabelFor(x => x[0].Status)</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
@Html.DisplayFor(model => item)
}
</tbody>
</table>
И в файле: Views \ DisplayTemplates \ AdminDetail.cshtml
@model AdminDetail
xxxxxxxxxxxxxxxxxxxxxxxx
<tr>
<td>@Html.DisplayFor(x => x.Order)</td>
<td>@Html.DisplayFor(x => x.Level)</td>
<td class="indent_@(adminDetail.Level)">@Html.DisplayFor(x => x.Title)</td>
<td>@Html.DisplayFor(x => x.Status)</td>
<td>@Html.ActionLink("Edit", "Edit",
new { pk = adminDetail.PartitionKey, rk = adminDetail.RowKey },
new { @class = "editLink" } )</td>
<td>@Ajax.ActionLink("Delete", "Delete", "Menus",
new { pk = adminDetail.PartitionKey, rk = adminDetail.RowKey },
new AjaxOptions {
HttpMethod = "POST",
Confirm = "Are you sure you want to delete menu item ",
OnSuccess = "deleteConfirmation"
})</td>
<td>@Html.DisplayFor(x => x.PartitionKey) @Html.DisplayFor(x => x.RowKey)</td>
</tr>
Когда появляется мое представление, я вижу данные для записей AdminDetails, но для <tr>
и <td>
нет форматирования. Я также не вижу никаких х. Я использую области, и код для представления находится внутри области. Возможно ли, что мой код не получает DisplayTemplate, потому что я использую области?
Вот пример того, как отображаются данные:
<table>
<thead>
<tr>
<th><label for="">Order</label></th>
<th><label for="">Order</label></th>
<th><label for="">Level</label></th>
<th><label for="">Title</label></th>
<th><label for="">Status</label></th>
</tr>
</thead>
<tbody>
<div class="display-label">PartitionKey</div>
<div class="display-field">01</div>
<div class="display-label">RowKey</div>
<div class="display-field">02</div>
<div class="display-label">Title</div>
<div class="display-field">Test55</div>
<div class="display-label">Status</div>
<div class="display-field">New</div>
<div class="display-label">Type</div>
<div class="display-field"></div>
<div class="display-label">Level</div>
<div class="display-field"></div>