在Controller Method中,我的代码在
下面ViewBag.CurrencyNameId = db.CurrencyNames;
在View.cshtml的View代码中
@Html.DropDownListFor(model => model.CurrencyNameId, new SelectList(ViewBag.CurrencyNameId, "Id", "Name",Model.CurrencyNameId), "Select", new { @class = "form-control" })
它没有设置初始值。