我正在尝试将超链接/动作链接放在我的表格标题中,以便进行排序,但出于某种原因,它们不会呈现。
知道为什么它没有正确渲染?在下面的代码中,您看到第一个表头是Actionlink。标题呈现为空。我检查了元素,它确实显得空洞。
代码:
@model PagedList.IPagedList<FitnerWebRole.ViewModels.CenterVM>
@using FitnerWebRole.Models
@using IdealDatabase
@{
ViewBag.Title = "Centers";
}
@using (IdealDb db = new IdealDb(ApiConfig.AppName, ApiConfig.DbServer, ApiConfig.DbUser, ApiConfig.DbPassword))
{
<div class="container adminContainer event">
<p>
@Html.ActionLink("Create New", "Create", null, new { @class = "btn btn-success" })
</p>
@Html.PagedListPager(Model, page => Url.Action("Index", new { page }), PagedList.Mvc.PagedListRenderOptions.Minimal)
<table id="centerTable" class="table">
<thead>
<tr>
<th>
@Html.ActionLink("Name", "Index", new { sortOrder = "name", currentSort = "name" })
</th>
<th>
@Html.DisplayNameFor(model => model.FirstOrDefault().Address)
</th>
<th>
@Html.DisplayNameFor(model => model.FirstOrDefault().ChainId)
</th>
<th>
@Html.DisplayNameFor(model => model.FirstOrDefault().CityId)
</th>
<th>
@Html.DisplayNameFor(model => model.FirstOrDefault().LangId)
</th>
<th>
@Html.DisplayNameFor(model => model.FirstOrDefault().Lat)
</th>
<th>
@Html.DisplayNameFor(model => model.FirstOrDefault().Lon)
</th>
<th></th>
</tr>
</thead>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Address)
</td>
<td>
@Chain.Get(db, item.ChainId).Name
</td>
<td>
@City.Get(db, item.CityId).Description
</td>
<td>
@Language.Get(db, item.LangId).Code
</td>
<td>
@Html.DisplayFor(modelItem => item.Lat)
</td>
<td>
@Html.DisplayFor(modelItem => item.Lon)
</td>
<td class="tableControls">
@Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
@Html.ActionLink("Details", "Details", new { id = item.Id }) |
<button id="delete" name="Center" value="@item.Id" class="btn btn-danger delete">Delete</button>
</td>
</tr>
}
</table>
Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount
@Html.PagedListPager(Model, page => Url.Action("Index", new { page }))
</div>
}