【发布时间】:2010-01-30 07:15:09
【问题描述】:
我的 ViewModel 中有 2 个属性
class ViewModel1
{
Dictonary<int, string> PossibleValues {get;set;}//key/value
int SelectedKey {get;set}
}
我想使用 Html.DropDownListFor 来编辑它
我想让 MVC 自动将数据序列化到 ViewModel 中/从 ViewModel 中序列化数据,这样我就可以进行以下操作了
public ActionResult Edit(ViewModel1 model) ...
实现此目的的最佳方法是什么?
【问题讨论】:
-
您使用的是 ASP.NET MVC 版本 1 还是 2?
标签: c# asp.net-mvc viewmodel