I am using viewbag
to put data in dropdownlist. In my edit page, I want to have selected value as the default value in my dropdown list.
I am sending dropdownlist from the controller class a开发者_运维百科s follows:-
ViewBag.WareHouseId = new SelectList(db.WareHouse, "ID","Description");
my view code for dropdownlist is:-
@Html.DropDownList("WareHouseID","SELECT")
what should I add in the above line to show previously selected value before changing the value of drop downlist.?
Pass the model value to the optionLabel parameter:
@Html.DropDownList("WareHouseID", "SELECT", Model.WareHouseID)
精彩评论