If you want to display multiple images, you can use the Html.ActionLink property in your View , as shown below. In this example, I use Detail / Edit / Delete images as a button in the Action column.
Note. Enter the Title , Controller and Action name in the Html.ActionLink according to your project. If you want to use an empty title, just enter "" for them.
.... //for using multiple Html.ActionLink in a column using Webgrid grid.Column("Action", 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>
As a complete example, you can look here: How to use WebGrid in cshtml view?
Sincerely.
Murat Yฤฑldฤฑz
source share