【发布时间】:2011-12-13 13:01:08
【问题描述】:
在我的 webgrid 中,我需要根据值显示图像 .. 代码如下
@model TraktorumMVC.Models.ManagePhotos
@{
ViewBag.Title = "ManagePhotos";
Layout = "~/Views/Shared/_Layout.cshtml";
var grid = new WebGrid(Model.AdPhotos);
}
@grid.GetHtml(
displayHeader: false,
columns: grid.Columns(
grid.Column(format: (item) =>
{
if (item.IsMainPreview == true)
{
return @<text><img src="@Url.Content("~/Content/images/preview-photo.gif")" alt="Image "/></text>;
}
else
{
return @<text><img src="@Url.Content("~/Content/images/non-preview-photo.gif")" alt="Image "/></text>;
}
}
),
grid.Column(format: (item) => Html.ActionLink("Remove Photo", "RemovePhoto", "Images", new { photoID = @item.Id }, new { @class = "RemovePhoto" }))
));
我不确定如何在 webgrid 中使用 if。我刚试过。它不起作用。出现以下错误
The best overloaded method match for 'System.Web.Helpers.WebGrid.Column(string, string, System.Func<dynamic,object>, string, bool)' has some invalid arguments
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-3 razor grid webgrid