C# 敲除未从post发送对象列表
我有一个C#对象,比如C# 敲除未从post发送对象列表,c#,asp.net-mvc,knockout.js,C#,Asp.net Mvc,Knockout.js,我有一个C#对象,比如 public class MyModel { public string ZipCode { get; set; } public DateTime DateOfEvent { get; set; } public List<Children> Applicants { get; set; } public string SelectedChoice { get; set; } } public class Childr
public class MyModel
{
public string ZipCode { get; set; }
public DateTime DateOfEvent { get; set; }
public List<Children> Applicants { get; set; }
public string SelectedChoice { get; set; }
}
public class Children
{
public string CoverageFor { get; set; }
public DateTime dateOfBirth { get; set; }
}
当我接到电话的时候
在控制器上
[System.Web.Mvc.HttpPost]
public ActionResult Start(MyModel model) <------- has all the values but the Children's property values not in.
{
//Stuff I will return
}
[System.Web.Mvc.HttpPost]
public Action Result Start(MyModel model)您在此选择中没有提到optionValue
<select name="coverageFor" id="5" data-bind="options: coverages, value:coverageFor, optionsText:'name', optionsCaption: 'Choose...'"></select>
这在服务器端是无效的,因为它需要一个string
not对象
换成
<select name="coverageFor" id="5" data-bind="options: coverages, value:coverageFor, optionsText:'name', optionsValue:'name', optionsCaption: 'Choose...'"></select>
<select name="coverageFor" id="5" data-bind="options: coverages, value:coverageFor, optionsText:'name', optionsCaption: 'Choose...'"></select>
coverageFor: { name: "self" }
<select name="coverageFor" id="5" data-bind="options: coverages, value:coverageFor, optionsText:'name', optionsValue:'name', optionsCaption: 'Choose...'"></select>