Currently I am working with ASP.Net MVC 6 using EF7. I am using the default controller generator. For some reason my drop downs are not populating with data on the create or edit page even though data is present.
Just to clarify the 3 select lists are being populated by 3 different tables that are all connected to the main table I am adding to.
Here's what I got.
Controller code
private readonly SchoolContext _context;
public SchoolsController(SchoolContext context)
{
_context = context;
}
public IActionResult Create()
{
ViewData["DistrictId"] = new SelectList(_context.Districts, "DistrictId", "District");
ViewData["LocationId"] = new SelectList(_context.Locations, "LocationId", "Location");
ViewData["TierId"] = new SelectList(_context.Tiers, "TierId", "Tier");
return View();
}
View code
@model School
is included at the top and here is what one of the select element looks like
<div class="form-group">
<label asp-for="DistrictId" class="col-md-2 control-label"></label>
<div class="col-md-10">
<select asp-for="DistrictId" class ="form-control"></select>
</div>
</div>
The select lists are completely blank with no errors there is data.
This is all generated automatically so I am totally clueless on what went wrong. Any suggestions?