如果你想显示多张图片,你可以在你的视图中使用 Html.ActionLink 属性,如下所示。在此示例中,我使用详细/编辑/删除图像作为操作列下的按钮。
注意: 根据您的项目在 Html.ActionLinks 中键入“Title”、“Controller”和“Action”名称。如果您使用空标题,只需使用“”。
....
//for using multiple Html.ActionLink in a column using Webgrid
grid.Column("Operations", format: (item) =>
new HtmlString(
Html.ActionLink("Show Details", "Edit", "Admin", new
{
applicantId = item.ApplicantID,
title = "Detail",
@class = "icon-link",
style = "background-image: url('../../Content/icons/detail.png')"
}, null).ToString() +
Html.ActionLink("Edit Record", "Edit", "Admin", new
{
applicantId = item.ApplicantID,
title = "Edit",
@class = "icon-link",
style = "background-image: url('../../Content/icons/edit.png')"
}, null).ToString() +
Html.ActionLink("Delete Record", "Edit", "Admin", new
{
applicantId = item.ApplicantID,
title = "Delete",
@class = "icon-link",
style = "background-image: url('../../Content/icons/delete.png')"
}, null).ToString()
)
)
....
<style type="text/css">
a.icon-link {
background-color: transparent;
background-repeat: no-repeat;
background-position: 0px 0px;
border: none;
cursor: pointer;
width: 16px;
height: 16px;
margin-right: 8px;
vertical-align: middle;
}
</style>
对于我的完整示例,您可以查看此处:How to use WebGrid in a cshtml view?
问候。