Html 未呈现表标题中的超链接
为了排序,我试图将超链接/操作链接放在我的表头中,但由于某些原因,它们不会呈现 知道为什么渲染不正确吗?在下面的代码中,您可以看到第一个表头是Actionlink。标题呈现为空。我检查了元素,它确实看起来是空的 代码:Html 未呈现表标题中的超链接,html,asp.net,asp.net-mvc,razor,Html,Asp.net,Asp.net Mvc,Razor,为了排序,我试图将超链接/操作链接放在我的表头中,但由于某些原因,它们不会呈现 知道为什么渲染不正确吗?在下面的代码中,您可以看到第一个表头是Actionlink。标题呈现为空。我检查了元素,它确实看起来是空的 代码: @model PagedList.IPagedList<FitnerWebRole.ViewModels.CenterVM> @using FitnerWebRole.Models @using IdealDatabase @{ ViewBag.Title
@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>
}
@model PagedList.IPagedList
@使用FitnerWebRole.Models
@使用IdealDatabase
@{
ViewBag.Title=“中心”;
}
@使用(IdealDb db=new IdealDb(ApiConfig.AppName、ApiConfig.DbServer、ApiConfig.DbUser、ApiConfig.DbPassword))
{
@ActionLink(“新建”、“创建”、null、新建{@class=“btn btn success”})
@PagedListPager(Model,page=>Url.Action(“Index”,new{page}),PagedList.Mvc.pagedListRenderations.Minimal)
@ActionLink(“Name”,“Index”,new{sortOrder=“Name”,currentSort=“Name”})
@DisplayNameFor(model=>model.FirstOrDefault().Address)
@DisplayNameFor(model=>model.FirstOrDefault().ChainId)
@DisplayNameFor(model=>model.FirstOrDefault().CityId)
@DisplayNameFor(model=>model.FirstOrDefault().LangId)
@DisplayNameFor(model=>model.FirstOrDefault().Lat)
@DisplayNameFor(model=>model.FirstOrDefault().Lon)
@foreach(模型中的var项目)
{
@DisplayFor(modelItem=>item.Name)
@DisplayFor(modelItem=>item.Address)
@Get(db,item.ChainId).Name
@Get(db,item.CityId).Description
@Language.Get(db,item.LangId).Code
@DisplayFor(modeleItem=>item.Lat)
@DisplayFor(modeleItem=>item.Lon)
@ActionLink(“编辑”,“编辑”,新的{id=item.id})|
@ActionLink(“详细信息”,“详细信息”,新的{id=item.id})|
删除
}
@Model.PageCount的@页(Model.PageCountUrl.Action(“Index”,new{page}))
}
你是说它呈现如下:
?是的,这是正确的。第一个表头是空的。我还尝试使用一个普通的锚定标记,结果是一样的。当我刷新我的页面时,我实际上可以在一瞬间看到它,然后它消失了。你有一些更新表格的脚本吗?你已经包含了两次@Html.PagedListPager(…)
?