【发布时间】:2019-12-27 19:11:38
【问题描述】:
enter image description hereenter image description here这是我的家庭控制器:
public class HomeController : Controller
{
private ApplicationDbContext _context;
public HomeController()
{
_context = new ApplicationDbContext();
}
public ActionResult Index()
{
var upcomingGigs = _context.Gigs
.Include(g => g.Artist)
.Include(g => g.Genre)
.Where(g => g.DateTime > DateTime.Now);
return View(upcomingGigs);
}
-
@foreach(模型中的 var gig)
{
-
@gig.DateTime.ToString("MMM")
@gig.DateTime.ToString("d")
@gig.Artist.Name
@model IEnumerable<BigHub.Models.Gig> @{ ViewBag.Title = "Home Page"; } <ul> @foreach (var gig in Model) { <li> <div class="date"> <div class="month"> @gig.DateTime.ToString("MMM") </div> <div class="day"> @gig.DateTime.ToString("d ") </div> </div> <div class="details"> <span class="artist"> @gig.Artist.Name </span> <span class="genre"> @gig.Genre.Name </span> </div> </li> } </ul>
}
此代码有效,但我得到了 输出为空。希望有人能帮忙。
这是我的预期输出
这是我的输出
【问题讨论】:
-
您能否详细说明您想要完成的任务,例如插图或现场示例?
-
请展示你到目前为止所做的尝试。
-
我正在调试但得到空的
标签: html asp.net-mvc-5