为什么这个 webgrid 迭代网格中的每一行?
@model IEnumerable<Blog.Domain.Model.BlogPost>
@{
ViewBag.Title = "Posts";
Layout = "~/Areas/Admin/Views/Shared/_AdminLayout.cshtml";
}
@Html.ActionLink("Add Post", "Add", "Blog")
@{
var grid = new WebGrid(Model);
}
@foreach (var items in Model)
{
<div id="grid">
@grid.GetHtml(columns: new[] {grid.Column("Title",header:""),
grid.Column("",header:"",format:(item)=>Html.ActionLink("More Details","Details","Blog",new{postId=items.Id},null)),
grid.Column("",header:"",format:(item)=>Html.ActionLink("Delete","Delete","Blog",new{postId=items.Id},null)),
grid.Column("",header:"",format:(item)=>Html.ActionLink("Edit","Edit","Blog",new {postId=items.Id},null)), })
</div>
}
我的意思是:例如对于两个数据,它呈现 4 个数据,每个数据两次!