我有两个型号如下动态生成的行细节不回发
public partial class provider_preapproval
{
public string encounter_type { get; set; }
public DateTime? e_start_date { get; set; }
public DateTime? e_end_date { get; set; }
public string status { get; set; }
public virtual IList<provider_diagnosis_dtls> provider_diagnosis_dtls { get; set; }
}
public partial class provider_diagnosis_dtls
{
public string diagnosis_code { get; set; }
public string diagnosis_desc { get; set; }
public string diagnosis_level { get; set; }
}
为同一的观点是
@using (Html.BeginForm("Preapprove", "Preapproval", FormMethod.Post)
{
@Html.LabelFor(model => model.encounter_type, htmlAttributes: new { id = "n", @class = "control-label" })
@Html.DropDownListFor(model => model.encounter_type, (SelectList)@ViewBag.Encounter, "---Select Encounter Type ---", new { @class = "m-wrap "
@Html.LabelFor(model => model.status, htmlAttributes: new { id = "n", @class = "control-label" }) @Html.TextBoxFor(model => model.status, new { id = "status", @Value = "New", @readonly = "readonly" })
@Html.LabelFor(model => model.e_start_date, htmlAttributes: new { id = "e_start", @class = "control-label " }) @Html.TextBoxFor(model => model.e_start_date, new { id = "start", @class = "m-wrap ", @Value = @TempData["service_date"], @readonly = "readonly" })
@Html.LabelFor(model => model.e_end_date, htmlAttributes: new { id = "e_end", @class = "control-label " }) @Html.TextBoxFor(model => model.e_end_date, new { id = "end", @class = "m-wrap datepicker", @Value = @TempData["service_date
//Template for dynamic generating row
<table id="Newdiagnosis" style="display:none">
<tr>
<td><input class="diag" style="width:200px" type="text" name="provider_diagnosis_dtls[#].diagnosis_code" value /></td>
<td><input class="diag_desc" style="width:500px" type="text" name="provider_diagnosis_dtls[#].diagnosis_desc" value /></td>
<td>
<input type="text" name="provider_diagnosis_dtls[#].diagnosis_level)" readonly value />
<input type="hidden" name="diagnosis.Index" value="%" />
</td>
</tr>
</table>
<table id="diagnosis" class="table table-striped table-hover table-bordered">
@if (Model != null)
{
for (int i = 0; i < Model.provider_diagnosis_dtls.Count; i++)
{
<tr>
<td>@Html.TextBoxFor(m => m.provider_diagnosis_dtls[i].diagnosis_code)</td>
<td>@Html.TextBoxFor(m => m.provider_diagnosis_dtls[i].diagnosis_desc)</td>
@Html.TextBoxFor(m => m.provider_diagnosis_dtls[i].diagnosis_level, new { @Value = "Primary", @readonly = "readonly" }) <input type="hidden" name="diagnosis.Index" value="@i" />
</td>
</tr>
}
</table>
}
现在我能够生成动态行表#diagnosis使用jquery并添加值,但在“Provider_preapproval”模型中发布“provider_diagnosis_dtls”Ilist时会显示null。
比这ILIST其他细节正在到来。
请告诉我在我的代码中有什么问题。
编辑
jQuery的
$(document).ready(function() {
$("#N").click(function() {
var index = (new Date()).getTime();
var clone = $('#Newdiagnosis').clone();
clone.html($(clone).html().replace(/\[#\]/g, '[' + index + ']'));
clone.html($(clone).html().replace(/"%"/g, '"' + index + '"'));
var html = clone.html();
$("#diagnosis").append(clone.html());
$("#diagnosis").find(".diag").last().tokenInput("@Url.Action("SearchDiagnosis","Preapproval")",
{
theme: 'facebook',
preventDuplicates: true,
searchingText: 'Searching...',
tokenLimit: 1
});
$("#diagnosis").find(".diag_desc").last().tokenInput("@Url.Action("SearchDiagnosis_desc","Preapproval")",
{
theme: 'facebook',
preventDuplicates: true,
searchingText: 'Searching...',
tokenLimit: 1
});
});
首先你不是通过jquery为你的模型属性赋值!你可以显示你的jQuery? –
您还需要显示帖子方法签名 –
您好Stephen,公共ActionResult Preapprove(provider_preapproval preapprove_dtl){.......}这是post方法签名.. – Sachu