实际的方法对我来说似乎很好,因为我可以检查SelectList中的字段: from variable in然后我使用DropDownListFor在视图上显示: g => g.SomePropertyInModel , selectList, new {variable.Property == selection,
Text = variabl
@model ViewModels.Foo.FooVm
@foreach(var item in Model.Bars) {@Html.DropDownListFor(model => item.BarId, ViewBag.Bars as IEnumerable<SelectListItem>, "Select bar
如何在控制器中创建SelectList并将其传递给视图?我需要将"-- Select --“选项的值设为0。这就是我目前所拥有的。ParentCategories = parentCategoriesList}@Html.DropDownListForx.ParentCategoryId, new SelectList(Model.ParentCategories, "I