POST控制器操作方法的LIST返回计数为0



这是一个简单的问题,我已经查看了所有相关的答案(有很多),并将我的代码与之进行了比较,我看不出哪里出了问题。

控制器

[HttpGet]public ActionResult PatInformation(长id){if(ModelState.IsValid){var patient=db.tblPatients.Find(id);PatientViewModels patientVM=_mapper.Map<PatientViewModels>(患者);return视图(patientVM);}return RedirectToAction("索引");}[HttpPost][ValidateAntiForgeryToken]公共操作结果PatientInformation(PatientViewModels模型){if(!ModelState.IsValid){return视图(模型);}tblPatienttblPatient=db.tblPatients.Find(model.PPatientID);tblPatient.Forename1=型号。前言1;tblPatient.Surname=型号。姓数据库。Entry(tblPatient).State=EntityState.Modified;数据库。SaveChanges();PatientViewModels patientsVM=_mapper.Map<PatientViewModels>(tbl患者);return View("PatientInformation",patientVM)

ViewModel

公共类PatientViewModels{公共PatientViewModels(){tblTumours=新列表<TumoursViewModel>();tblGP=新的tblGP();tblAddress=新的tblAddress();}公共长PatientID{get;set;}公开时间长?HSCNO{get;set;}公共字符串姓氏{get;set;}公共字符串Forename1{get;set;}公共字符串Forename2{get;set;}公共字符串PrevName{get;set;}公开时间长?PatAddress{get;set;}公开时间长?PatGP{get;set;}公共字符串BirthGender{get;set;}公开日期时间?DOB{get;set;}公开替身?民族{get;set;}公共字符串VitalStatus{get;set;}公开日期时间?创建日期{get;set;}公开日期时间?日期修正{get;set;}公开替身?OldID{get;set;}公开时间长?NICR编号{get;set;}公共虚拟tblAddress tblAddress{get;set;}公共虚拟tblGP tblGP{get;set;}公共虚拟列表<TumoursViewModel>tblTumours{get;set;}公共字符串FullAddress{get;set;}公共字符串年龄{get;set;}}公共类TumoursViewModel{public long TumourID{get;set;}public Nullable<双>汤否{get;set;}public Nullable<long>PatientID{get;set;}公共字符串ICD03{get;set;}公共字符串ICD10{get;set;}公共虚拟tbl形态tbl形态{get;set;}公共虚拟tblBehavior公共虚拟tblAddress tblAddress{get;set;}public Nullable<System.DateTime>DateOfDiag{get;set;}公共字符串转移函数{get;set;}公共字符串TumourStatus{get;set;}public Nullable<双>StageGrade{get;set;}public PatientViewModels Patients{get;set;}}
<表id=";tbl肿瘤";class=";表"><thead><tr><th>汤Id<th><th>ICD03站点<th><th>ICD10站点<th><th>形态学<th><th>行为<th><th>诊断<th><th>方法<th><th>状态<th><th>最后阶段/完成<th><tr><thead><tbody>@for(int i=0;i<Model.tblTumours.Count;i++){<tr类=";表行";数据href="Url.Action("肿瘤信息","肿瘤",new{tumourId=Model.tblTumours[i].tumourId,patientId=Model.patientId})"><td class=";pt-3-半";hidden=";真">Html.TextBoxFor(m=>Model.tblTumours[i].TumourID,new{Class="表单控件"<td><td class=";pt-3-半">Html.TextBoxFor(m=>Model.tblTumours[i].TumourNo,new{Class="表单控件"<td><td class=";pt-3-半">Html.HiddFor(m=>Model.tblTumours[i].ICD03,new{Class="表单控件"<td><td class=";pt-3-半">Html.TextBoxFor(m=>Model.tblTumours[i].ICD03,new{Class="表单控件"})<td><td class=";pt-3-半">Html.TextBoxFor(m=>Model.tblTumours[i].ICD10,new{Class="表单控件"})<td><td class=";pt-3-半">Html.TextBoxFor(m=>Model.tblTumours[i].tblMorphology.morphology_code,new{Class="form control"<td><td class=";pt-3-半">Html.TextBoxFor(m=>Model.tblTumours[i].tblBehaviour.BehaviourCode,new{Class="表单控件"<td><td class=";pt-3-半">Html.TextBoxFor(m=>Model.tblTumours[i].DateOfDiag,new{Class="表单控件"<td><td class=";pt-3-半">Html.TextBoxFor(m=>Model.tblTumours[i].Metacases,new{Class="form control"})<td><td class=";pt-3-半">lt;span class=";徽章警告">Html.TextBoxFor(m=>Model.tblTumours[i].TumourStatus,new{Class="表单控件"})<span>lt/td><td class=";pt-3-半">Html.TextBoxFor(m=>Model.tblTumours[i].SstageGrade,new{Class="表单控件"<td><tr>}<tbody><表>

当我发布带有tblTumours List的控制器时,总是返回as count=0。我确信这是一个简单的解决方案,但我就是看不到。

希望有人能帮上忙,请坦白,因为我刚开始是一名开发人员,并继承了这一点。谢谢

试试这个

@using (Html.BeginForm("PatientInformation", "YourController", FormMethod.Post))
{
<table id="tblTumours" class="table">
<thead>
<tr>
<th>Tumour Id</th>
<th>ICD03 Site</th>
<th>ICD10 Site</th>
<th>Morphology</th>
<th>Behaviour</th>
<th>Diagnosis</th>
<th>Method</th>
<th>Status</th>
<th>Final Stage / Complate</th>
</tr>
</thead>
<tbody>
@for (int i = 0; i < Model.tblTumours.Count; i++)
{
<tr class="table-row" data-href="@Url.Action(" TumourInformation", "Tumours" , new { tumourId=Model.tblTumours[i].TumourID, patientId=Model.PatientID })">
<td class="pt-3-half" hidden="true">@Html.TextBoxFor(m => Model.tblTumours[i].TumourID, new { Class = "form-control" })</td>
<td class="pt-3-half">@Html.TextBoxFor(m => Model.tblTumours[i].TumourNo, new { Class = "form-control" })</td>
<td class="pt-3-half">@Html.HiddenFor(m => Model.tblTumours[i].ICD03, new { Class = "form-control" })</td>
<td class="pt-3-half">@Html.TextBoxFor(m => Model.tblTumours[i].ICD03, new { Class = "form-control" })</td>
<td class="pt-3-half">@Html.TextBoxFor(m => Model.tblTumours[i].ICD10, new { Class = "form-control" })</td>
<td class="pt-3-half">@Html.TextBoxFor(m => Model.tblTumours[i].tblMorphology.morphology_code, new { Class = "form-control" })</td>
<td class="pt-3-half">@Html.TextBoxFor(m => Model.tblTumours[i].tblBehaviour.BehaviourCode, new { Class = "form-control" })</td>
<td class="pt-3-half">@Html.TextBoxFor(m => Model.tblTumours[i].DateOfDiag, new { Class = "form-control" })</td>
<td class="pt-3-half">@Html.TextBoxFor(m => Model.tblTumours[i].Metastases, new { Class = "form-control" })</td>
<td class="pt-3-half"><span class="badge badge-warning">@Html.TextBoxFor(m => Model.tblTumours[i].TumourStatus, new { Class = "form-control" })</span></td>
<td class="pt-3-half">@Html.TextBoxFor(m => Model.tblTumours[i].StageGrade, new { Class = "form-control" })</td>
</tr>
}

</tbody>
</table>
}
public class PatientViewModels
{
public PatientViewModels()
{           
tblGP = new tblGP();
tblAddress = new tblAddress();
}
// Your code
}