在我看来,以下代码输出以下内容:
ViewBag.Count = 4
39d3fe7f-fb1c-4c0f-948e-43093f1d7f85 265ca3c1-9890-4680-b10c-8c7c5e22b26f
f07f0aee-3948-473a-873f-74d446030d36 229db054-e62c-4981-878e-cd0bd5c9a1ac
a92440cd-9393-4d1b-abfb-e705ea739c59 4cd997cf-1715-43b0-9354-0ddf90f33fe6
7c265ae0-7c8e-4dd3-ae76-f52e95138b6e 45254c9a-f078-4d50-bdc8-3e823bdcce41
看法:
ViewBag.Count = @ViewBag.Count
<table>
@foreach (var item in Model)
{
<tr>
<td>@item.ID</td>
<td>@item.USER_ID</td>
</tr>
}
</table>
@Html.Grid(Model)
如果 ViewBag 中有四条记录,那么为什么 MvcContrib Grid 没有列出它们?
这是我的控制器:
public ActionResult Index()
{
ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
ViewBag.Count = db.Directories.Count();
return View(db.Directories.ToList());
}
谢谢你。
编辑:
查看源代码只显示一个空表:
<table class="grid"><thead><tr></tr></thead><tbody><tr class="gridrow"></tr><tr class="gridrow_alternate"></tr><tr class="gridrow"></tr><tr class="gridrow_alternate"></tr></tbody></table>