我在控制器匿名列表DropDownListFor
public ActionResult Create()
{
ViewBag.CustomerList = new SelectList(db.Customers.Select(m => new { Id = m.Id, m.Name, m.LastName }));
return View();
}
,并在视图
@Html.DropDownListFor(model => model.Customer.Id, (SelectList)ViewBag.CustomerList, "", new { @class = "form-control" })
,但在浏览器中写了这个代码,我得到这样的结果在下拉
我该如何解决这个问题?
,谢谢你的回答,但我不想创建模型,可以做这个工作就像我的做法? – mic