我有一个基本的ViewModel,其属性是一个复杂类型的List.绑定时,我似乎不知道要么获取值列表,要么根据发布的值(即视图排列)获取其他模型属性.
视图模型:
public class MyViewModel
{
public int Id { get; set; }
public string Property1 { get; set; }
public string Property2 { get; set; }
public List<MyDataItem> Data { get; set; }
}
public class MyDataItem
{
public int Id { get; set; }
public int ParentId { get; set; }
public string Name { get; set; }
public string Value { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
控制器动作:
public ActionResult MyForm()
{
MyViewModel model = new MyViewModel();
model.Id = …Run Code Online (Sandbox Code Playgroud)