次のコードを使用して、ドロップダウン リストの LOV を取得し、選択した値も設定します。
ViewData["dropDown_Color"] = correspondingDropDownValue
.Select(j =>
new SelectListItem {
Text = j.ListOfValue,
Value = j.ListOfValue,
Selected = j.ListOfValue
== x.DefaultValue
})
.ToList();
にドロップダウンリストができたので、次のクエリでこのベースViewData
の選択された値を更新したいと思いますViewData["dropDown_Color"]
var userPref = from m in db.UserColorPref
where m.UserID.Equals(userSessionID)
select m;
更新する値には、 からアクセスできますuserPref.color
。目的を達成する方法を教えてください。