I'm working on an asp.net mvc project.
I've been able to combine 2 fields from a table into a drop down list. However, in both the create and index views, I get these "{ }" brackets and I can't figure out how to get rid of them.
Controller: //Get: /Create
var units = db.EquipmentLists
.Where(s => s.Unit != null)
.OrderBy(s => s.Unit)
.Select(s => new
{
Description = s.Unit + " - " + s.MakeModel
}).ToList();
ViewBag.Units = new SelectList(units);
//Post: /Create
ViewBag.Units = new SelectList(db.EquipmentLists.OrderBy(x => x.Unit + " - " + x.MakeModel));
Create.cshtml
@Html.DropDownListFor(model => model.Unit, (SelectList)ViewBag.Units, "Select one...", htmlAttributes: new { @class = "form-control" })
Don't know why I'm getting the "{ }"
brackets in the views. Just want to get rid of them. Any help would be appreciated.