----- Вариант 1
Контроллер:
var ExpectedShipmentsRange = new List ();
ExpectedShipmentsRange.Add(new SelectListItem() { Text = "Selected number of shipments", Value="0", Disabled = true, Selected = true });
ExpectedShipmentsRange.Add(new SelectListItem() { Text = "0 to 20 shipments", Value = "0-20" });
ExpectedShipmentsRange.Add(new SelectListItem() { Text = "20 to 40 shipments", Value = "20-40" });
ViewBag.ExpectedShipmentsRange = ExpectedShipmentsRange;
Вид:
@Html.DropDownListFor(m => m.ExpectedShipments, (IEnumerable<SelectListItem>)@ViewBag.ExpectedShipmentsRange, new { @class = "form-control" })
----- Вариант 2
Контроллер:
ViewBag.citiesSa = _dbContext.Countries.ToList();
Вид:
@Html.DropDownListFor(m => m.City, new SelectList(@ViewBag.citiesSa, "Id", "Name"), "Select your city", new { @class = "form-control" })
----- Опция 3 не поддерживает отключенную опцию:
List<SelectListItem> ExpectedShipmentsRange = new List<SelectListItem>();
ExpectedShipmentsRange.Add(new SelectListItem() { Text = "0 to 20 shipments", Value = "0-20" });
ExpectedShipmentsRange.Add(new SelectListItem() { Text = "20 to 40 shipments", Value = "20-40" });
ViewBag.ExpectedShipmentsRange = new SelectList(ExpectedShipmentsRange, "Value", "Text");
Вид:
@Html.DropDownListFor(m => m.ExpectedShipments, (SelectList)@ViewBag.ExpectedShipmentsRange, new { @class = "form-control" })