Ran*_*ser 14 c# asp.net-mvc razor mvcgrid
我正在开发一个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>
}
Run Code Online (Sandbox Code Playgroud)
它工作正常,我能够将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)
Run Code Online (Sandbox Code Playgroud)
我在Nx1单元格中获得的输出是:
<a href="/Showcase/ViewProduct/?productID=15">Galaxy Note 3</a>
Run Code Online (Sandbox Code Playgroud)
期望的输出: Galaxy Note 3
请帮帮我.谢谢.
Ran*_*ser 18
这解决了这个问题
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());
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17455 次 |
| 最近记录: |