问题是如何foreach
将数据建模到该局部视图。我正在使用ASP.net CORE。
ProgramController
public IActionResult Create(){
var items = context.Customs.ToList();
return View("Views/Account/Partial.cshtml",items);
}
Register.cshtml
<form asp-route-returnUrl="@ViewData["ReturnUrl"]" method="POST">
...
@Html.Partial("Partial")
...
</form>
Partial.cshtml
@model IEnumerable<ClaimBased.Models.CustomModel>
@foreach(var items in Model){
<p>@Html.DisplayFor(modelItem => items.Name)</p>
}