我正在开发一个 ASP.net MVC 应用程序。
早些时候,我使用以下代码显示产品表。
foreach (var item in Model)
{
<div class="row">
<div class="cell">
@Html.ActionLink(item.productName, "ViewProduct", "Showcase",
new { productID = item.productID }, null)
</div>
<div class="cell">
@item.quantity
</div>
<div class="cell">
@item.price
</div>
</div>
}
它工作得很好,我能够将 Nx1 的元素作为链接重定向到显示产品详细信息的视图。
然后我想使用 MVC.Grid Nuget 包实现 GridView 来显示产品表。
网格工作正常,但我不能将 Nx1 的元素作为链接,以便我可以重定向。
我试过这个,但它不工作。
@Html.Grid(Model).Columns(columns =>{
columns.Add(model => model.productName).Titled("Name").Filterable(true)
.RenderValueAs(o => Html.ActionLink(o.productName, "ViewProduct", "Showcase",
new { productID = o.productID }, null));
columns.Add(model => model.quantity).Titled("Quantity Available");
columns.Add(model => model.price).Titled("Price");
}).WithPaging(3).Sortable(true)
我在 Nx1 单元中得到的输出是:
<a href="/Showcase/ViewProduct/?productID=15">Galaxy Note 3</a>
所需输出: Galaxy Note 3
请帮帮我。谢谢。