开发者

how can get previously selected value in dropdown list in edit page

开发者 https://www.devze.com 2023-03-13 06:21 出处:网络
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 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)
0

精彩评论

暂无评论...
验证码 换一张
取 消