I Have MVC Razor view with lot of DropDrownFor. i wanna set default value to that DropdownListFor.
This is my View:
@Html.DropDownListFor(model => model.DestCountryId, ViewBag.CountryIdList as SelectList, "select", new { @class = "form-control input-sm" })
This is my ViewBag:
ViewBag.CountryIdList = new SelectList(db.Countries.Where(a => a.Currency != null), "Id", "Name");
Ho w to set Default value in this scenario
See Question&Answers more detail:os