2

我有一个 View 呈现一个 AgreementSearch 对象的 EditorFor,它又具有一个 BaseEmployeeSearch 对象的 EditorFor,因为 AgreementSearch 继承自 BaseEmployeeSearch。问题是 BaseEmployeeSearch 对象的 EditorFor 返回,其中没有任何内容。

当单独使用时,BaseEmployeeSearch 对象 EditorTemplate 工作得很好,如果问题是由于名称错误或其他原因,我希望对象的 .ToString 编辑器默认出现。

有人可以对此有所了解吗?

协议搜索编辑模板:

@model TimecardRepository.Models.AgreementsModels.BusinessObject.AgreementSearch

@Html.EditorForModel("_BaseEmployeeSearch")

<h4>HEY THERE!</h4>

<span class="margin_left_2em">
@Html.LabelFor(x => x.AgreementStatus, "Filter by agreement Type: ")
@Html.DropDownListFor(x => x.AgreementStatus, new SelectList(new[] 
            { 
                new { desc = "All agreement types", value = "0" }, 
                new { desc = "Disagreements Only", value = "1" }, 
                new { desc = "Agreements Only", value = "2" }, 
                new { desc = "Awaiting Agreement", value = "3" }  
            }, "value", "desc", (Model != null) ? Model.AgreementStatus : 0))
</span>

<span class="margin_left_2em">
@Html.LabelFor(x => x.AgreementStatus, "Filter by last comment: ")
@Html.DropDownListFor(x => x.AgreementStatus, new SelectList(new[] 
            { 
                new { desc = "All comment types", value = "0" }, 
                new { desc = "No comments", value = "1" }, 
                new { desc = "Last comment from Payroll", value = "2" },
                new { desc = "Last comment from Field", value = "3" }  
            }, "value", "desc", (Model != null) ? Model.CommentStatus : 0))
</span>

BaseEmployeeSearch 编辑模板

@model TimecardRepository.Models.Shared.BaseEmployeeSearch

<span>
@Html.LabelFor(model => Model.FirstName, "First: ")
@Html.TextBoxFor(model => Model.FirstName, new { style = "width: 7em;", maxlength = "12" })
</span>
<span class="margin_left_2em">
@Html.LabelFor(model => Model.LastName, "Last: ")
@Html.TextBoxFor(model => Model.LastName, new { style = "width: 7em;", maxlength = "12" })
</span>
<span class="margin_left_2em">
@Html.LabelFor(model => Model.MemberID, "SMID: ")
@Html.TextBoxFor(model => Model.MemberID, new { style = "width: 6em;", maxlength = "7" })
</span>
<span class="margin_left_2em">
@Html.LabelFor(model => Model.Entity, "Entity: ")
@Html.TextBoxFor(model => Model.Entity, new { style = "width: 5em;", maxlength = "6" })
</span>
<span class="margin_left_2em">
@Html.LabelFor(model => Model.PayPeriod.Offset, "Pay Period: ")
@Html.DropDownListFor(model => Model.PayPeriod.Offset, new SelectList(new[] { new { desc = "Current", value = "0" }, new { desc = "Next", value = "1" }, new { desc = "Previous", value = "-1" } }, "value", "desc"))

@Html.HiddenFor(model => Model.PayPeriod.StartDate)
@Html.HiddenFor(model => Model.PayPeriod.EndDate)
</span>    
4

0 回答 0