ASP.net MVC将单元格内容作为Grid.MVC中的链接
我正在开发一个ASP.net MVC应用程序。
之前我使用以下代码显示产品表。
foreach (var item in Model) { @Html.ActionLink(item.productName, "ViewProduct", "Showcase", new { productID = item.productID }, null) @item.quantity @item.price }
它工作正常,我能够将Nx1’st元素作为链接重定向到显示产品细节的视图。
然后我想使用MVC.Grid Nuget包实现GridView来显示产品表。
网格工作正常,但我不能将Nx1’st元素作为链接,以便我可以重定向。
我试过这个,但它不起作用。
@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单元格中获得的输出是:
Galaxy Note 3
期望的输出: Galaxy Note 3
请帮帮我。 谢谢。
这解决了这个问题
columns.Add(model => model.productName).Titled("Name") .Filterable(true).Sanitized(false).Encoded(false). RenderValueAs(model => Html.ActionLink(model.productName, "ViewProduct", "Showcase", new { productID = model.productID }, null) .ToHtmlString());