我正在开发一个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'st元素作为链接重定向到显示产品详细信息的视图。
然后我想用MVC实现GridView来显示产品表。Grid Nuget包。
Grid工作得很好,但我不能使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单元中得到的输出是:
<a href="/Showcase/ViewProduct/?productID=15">Galaxy Note 3</a>
所期望的输出: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());