This is part of a .NET MVC project.
I have a DropDownList that is populated by an array of strings from my model. The actual list functions fine and populates correctly, but when an item is selected, there is no value passed. The value should just be equal to the text being selected from the dropdownlist.
I can see that it likely isn't assigned anywhere, but I'm relatively inexperienced with MVC/HTML projects.
<div class="form-group">
@Html.LabelFor(model => model.Cores, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownList("Cores", null, htmlAttributes: new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Cores, "", new { @class = "text-danger" })
</div>
</div>
The code I'm using is modified from a larger project that I've (apparently) taken over, so I'm learning as I go with this.
EDIT:
This is how the list of cores is initialized and passed to the view page.
var cores = db.Cores.ToList();
var coreName = new List<string>();
foreach (Core core in cores)
{
coreName.Add(core.Name);
}
ViewBag.Cores = new SelectList(coreName);
return View();