Asp.net 将链接添加到webgrid中
我正在开发一个mvc.NETWeb应用程序。我使用webgrid显示数据库中的数据Asp.net 将链接添加到webgrid中,asp.net,asp.net-mvc,asp.net-mvc-3,razor,webgrid,Asp.net,Asp.net Mvc,Asp.net Mvc 3,Razor,Webgrid,我正在开发一个mvc.NETWeb应用程序。我使用webgrid显示数据库中的数据 @{ var grid = new WebGrid(Model, canPage:true , rowsPerPage :6); grid.Pager(WebGridPagerModes.NextPrevious); @grid.GetHtml(tableStyle: "webGrid", htmlAttributes: new {id="datatable" },hea
@{
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个操作链接。如何做到这一点。以下是我的操作链接(我使用图像而不是文本)
来自SO的多个答案
<a href="@Url.Action("Edit", new { id=MyId })"><img src="@Url.Content("~/Content/Images/Image.bmp")", alt="Edit" /></a>
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>)
@Html.ActionLink("Update", "Update", @item.Price, new { @class = "imgLink"})
.imgLink
{
background: url(YourImage.png) no-repeat;
}
明智地选择;)
:
@Html.ActionLink("Update", "Update", new{@postID =@item.PostID}, new { @class = "imgLink"})
来自SO的多重回答
<a href="@Url.Action("Edit", new { id=MyId })"><img src="@Url.Content("~/Content/Images/Image.bmp")", alt="Edit" /></a>
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>)
@Html.ActionLink("Update", "Update", @item.Price, new { @class = "imgLink"})
.imgLink
{
background: url(YourImage.png) no-repeat;
}
明智地选择;)
:
@Html.ActionLink("Update", "Update", new{@postID =@item.PostID}, new { @class = "imgLink"})
事实上,这些链接用于编辑、删除和显示每行的详细信息。请帮助您只想要图像,或者甚至文本很酷?事实上,我已经找到了一种使用文本的方法,但我想要图像^^谢谢您,yasserOK,请看,您应该得到它:)事实上,这些链接用于编辑、删除和显示每行的详细信息。请帮忙你只想要图片或者文字很酷?事实上我已经找到了一种使用文字的方法,但是我想要图片^^谢谢你,yasserOK,看到了,你应该明白了:)很酷,但我这里有个问题,我的视图有一个IEnuerable模型,我不知道如何将当前行的id作为操作链接的参数传递给操作链接
@model IEnumerable
你在使用3种方法中的哪一种?下面是解决方案:grid.Column(“,”,format:(item)=>@Html.ActionLink(“修饰符”,“编辑”,新的{id=item.id_client})
最后一个问题Yasser^。我希望所有这些链接都显示在同一列中,如何实现?很酷,但我有问题,我的视图有一个IEnuerable模型,我不知道如何将当前行的id作为操作链接的参数传递@model IEnumerable
您使用的是3种方法中的哪一种?以下是解决方案:grid.Column(“,”,format:(item)=>@Html.ActionLink(“Modifier”,“Edit”,new{id=item.id\u client}))
最后一个问题Yasser^^。我希望所有这些链接都显示在同一列中,如何实现?