我正在开发一个mvc .net web应用程序。我使用webgrid来显示数据库中的数据。
@{
var grid = new WebGrid(Model, canPage:true , rowsPerPage :6);
grid.Pager(WebGridPagerModes.NextPrevious);
@grid.GetHtml(tableStyle: "webGrid", htmlAttributes:
new {id="datatable" },headerStyle: "Header", alternatingRowStyle : "alt",
columns: grid.Columns(grid.Column("Nom"), grid.Column("Prenom"),
grid.Column("Email")));
}
我只想在每行添加3个操作链接。怎么做。这是我的动作链接(我使用图像而不是文本)
<a href="@Url.Action( "Details", new { id = item.id_client })">
<img src="~/Images/details.png" alt =""/></a>
<a href="@Url.Action( "Edit", new { id = item.id_client })">
<img src="~/Images/modifier.png" alt =""/></a>
<a href="@Url.Action( "Delete", new { id = item.id_client })">
<img src="~/Images/supprimer.png" alt =""/></a>
答案 0 :(得分:4)
Muliple从SO回答
<强> Method 1 强>
<a href="@Url.Action("Edit", new { id=MyId })"><img src="@Url.Content("~/Content/Images/Image.bmp")", alt="Edit" /></a>
<强> Method 2 强>
grid.Column(header: "Details",
format: @<text><img src="@Url.Content("~/Content/Images/view-fullscreen.png")"
style="cursor: pointer" onclick="openPopup('@item.EncryUserId')"
alt="View Detail" title="View Detail"/></text>)
<强> Method 3 强>
@Html.ActionLink("Update", "Update", @item.Price, new { @class = "imgLink"})
.imgLink
{
background: url(YourImage.png) no-repeat;
}
明智地选择;)
Update :
@Html.ActionLink("Update", "Update", new{@postID =@item.PostID}, new { @class = "imgLink"})