Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 模型内的列表集合未发回控制器_C#_Asp.net Mvc 3_Razor - Fatal编程技术网

C# 模型内的列表集合未发回控制器

C# 模型内的列表集合未发回控制器,c#,asp.net-mvc-3,razor,C#,Asp.net Mvc 3,Razor,在过去的24小时里,我无从得知这一点。我有一个模型,其中填充了一个集合对象并将其渲染到视图中。一切都很好地呈现和发回,当我将表单发回控制器时,列表TestExceptionDisplay为空/空。请帮帮我,这让我发疯了,我已经尝试了几种不同的方法,但现在却不知所措 基本上在视图的末尾有一个foreach循环,我在其中渲染 TestExceptionDisplay属性,我确实为表单集合维护了一个索引,以便在post上重新获取它,但毫无用处,它总是空的。它渲染得很好,每个项目都使用正确的索引正确显示

在过去的24小时里,我无从得知这一点。我有一个模型,其中填充了一个集合对象并将其渲染到视图中。一切都很好地呈现和发回,当我将表单发回控制器时,列表TestExceptionDisplay为空/空。请帮帮我,这让我发疯了,我已经尝试了几种不同的方法,但现在却不知所措

基本上在视图的末尾有一个foreach循环,我在其中渲染 TestExceptionDisplay属性,我确实为表单集合维护了一个索引,以便在post上重新获取它,但毫无用处,它总是空的。它渲染得很好,每个项目都使用正确的索引正确显示

public class RunLogEntryTestExceptionDisplay
{
        public string Exception { get; set; }

}


@model RunLog.Domain.Entities.RunLogEntry
@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_Layout.cshtml";

}
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/errorCode.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/testexception.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/runLogEntry.js")" type="text/javascript"></script>
<script type="text/javascript">
    var runlogListErrorsUrl = '@Url.Action("ListErrorCodes", "RunLogEntry")';
    var runlogTestExceptionUrl = '@Url.Action("ListTestExceptions", "RunLogEntry")';


</script>
<fieldset>
    <legend>Enter a new Run Log Entry</legend>
    @using (Html.BeginForm("Create", "RunLogEntry", FormMethod.Post, new { enctype = "multipart/form-data" }))
    {
        @Html.ValidationSummary(true)
        <div class="exception">@(ViewBag.ErrorMessage)</div>
        <div class="bodyContent">
            <span class="leftContent">Load List File (Select): </span><span class="rightContent">
                <input type="file" name="file" id="file1" style="width: 500px" />
            </span>
        </div>
                           if (Model.LoadListStoredFileName != null)
                           {
        <div class="bodyContent">
            <span class="leftContent">Attached Load List: </span><span class="rightContent">
                @Html.ActionLink(Model.LoadListFileName, "Download", new { @file = Model.LoadListStoredFileName })
            </span>
        </div>
                           }
        <div class="bodyContent">
            <span class="leftContent">Output File (Select): </span><span class="rightContent">
                <input type="file" name="file" id="file2" style="width: 500px" />
            </span>
        </div>
                           if (Model.OutputStoredFileName != null)
                           {
        <div class="bodyContent">
            <span class="leftContent">Attached Output: </span><span class="rightContent">
                @Html.ActionLink(Model.OutputFileName, "Download", new { @file = Model.OutputStoredFileName })
            </span>
        </div>
                           }
        <div class="bodyContent">
            <span class="leftContent">Import Files: </span>
            <button name="submit" class="art-button" type="submit" value="Upload" style="width: 100px">
                Upload</button>
            <button name="submit" class="art-button" type="submit" value="Remove" style="width: 100px">
                Remove</button>
        </div>
        <div class="bodyContent">
            <span class="leftContent">
                @Html.Label("Operator")
            </span><span class="rightContent">
                @Html.DropDownList("OperatorID", String.Empty)
            </span>
        </div>
        <div class="bodyContent">
            <span class="leftContent">
                @Html.Label("Run ID")
            </span><span class="rightContent">[Generated] </span>
        </div>
        <div class="bodyContent">
            <span class="leftContent">
                @Html.Label("Run Start Date / Time")
            </span><span class="rightContent">
                @Html.EditorFor(model => model.RunDate)
                &nbsp;
                @Html.DropDownList("Hour", ListHelpers.HourList())
                :
                @Html.DropDownList("Minute", ListHelpers.Minute15List())
                &nbsp;
                @Html.DropDownList("AMPM", ListHelpers.AMPMList())
            </span>
        </div>
        <div class="bodyContent">
            <span class="leftContent">
                @Html.Label("System")
            </span><span class="rightContent">
                @Html.DropDownList("SystemID", String.Empty)
            </span>
        </div>
        <div class="bodyContent">
            <span class="leftContent">
                @Html.Label("Run Type")
            </span><span class="rightContent">
                @Html.DropDownList("RunTypeID", String.Empty)
            </span>
        </div>
        <div class="bodyContent">
            <span class="leftContent">
                @Html.Label("Run Description")
            </span><span class="rightContent">
                @Html.TextAreaFor(model => model.RunDescription, new { style = "width: 600px; height=30px" })
            </span>
        </div>
        <div class="bodyContent">
            <span class="leftContent">
                @Html.Label("Assay Performance Issues")
            </span><span class="rightContent">
                @Html.DropDownList("AssayPerformanceIssues1", ListHelpers.YesNoList())
            </span>
        </div>
        <div class="bodyContent">
            <span class="leftContent">
                @Html.Label("Tests/Cycles Requested")
            </span><span class="rightContent">
                @Html.EditorFor(model => model.SPTestsRequested)
            </span>
        </div>
        <div class="bodyContent">
            <span class="leftContent">
                @Html.Label("Tests/Cycles Completed")
            </span><span class="rightContent">
                @Html.EditorFor(model => model.SPTestsCompleted)
            </span>
        </div>
        <div class="bodyContent">
            <span class="leftContent">
                @Html.Label("Run Status")
            </span><span class="rightContent">
                @Html.DropDownList("RunStatusID", String.Empty)
            </span>
        </div>
        <div class="bodyContent">
            <span class="leftContent">
                @Html.Label("Assay")
            </span><span class="rightContent">
                @Html.ListBoxFor(model => model.SelectedAssayIDs, new MultiSelectList(RunLog.Domain.Lists.GlobalList.AssayListItems(), "ID", "Name", Model.SelectedAssayIDs))
            </span>
        </div>
        <div class="bodyContent">
            <span class="leftContent">
                @Html.Label("Error Code")
            </span><span class="rightContent"><span id="ChildDialogLink" class="treeViewLink">Click
                here to Select Error Codes</span>
                <br />
                <span id="ErrorCodeDisplay" style="cursor: pointer; text-decoration: underline;">@(Model.ErrorDescription)</span>
                @Html.HiddenFor(model => model.ErrorDescription)
            </span>
        </div>

        <div class="bodyContent">
            <span class="leftContent">
                @Html.Label("Test Exceptions")
            </span><span class="rightContent"><span id="TestExceptionChildDialogLink" class="treeViewLink">
                Click here to View Test Exceptions</span>
                <br />
                <span id="TestExceptionDisplay"></span></span>
        </div>

        <div class="bodyContent">
            <span class="leftContent">
                @Html.Label("Service Entry Request")
            </span><span class="rightContent">
                @Html.DropDownList("ServiceRequest", ListHelpers.YesNoList())
            </span>
        </div>
        <div class="bodyContent">
            <span class="leftContent">
                @Html.Label("Problem Description")
            </span><span class="rightContent">
                @Html.TextArea("ProblemDescription", new { style = "width: 600px; height: 30px" })
            </span>
        </div>
        <p>
            <input id="LogType" type="hidden" value="Run" />
            <input id="ID" type="hidden" value="0" />
            @if (Model.ExitCode == "1")
            {
                @Html.Hidden("ExitCode", Model.ExitCode)
            }
            else
            {
                <input id="ExitCode" type="hidden" value='0' />
            }
        </p>

        <div id="testExceptiontreeview" title="Dialog Title" style="font-size: 10px; font-weight: normal;
            overflow: scroll; width: 800px; height: 450px;">
            <div id="testExceptions">
            </div>
            <div id="inputTestExceptions">
                <table class="grid" style="width: 450px; margin: 3px 3px 3px 3px;">
                    <thead>
                        <tr>
                            <th>
                                Exception String
                            </th>
                            <th>
                                Comment
                            </th>
                        </tr>
                    </thead>
                    @{var index = 0;}
                    @if (Model.TestExceptionDisplay != null)
                    {
                        foreach (var p in Model.TestExceptionDisplay)
                        {
                        <tr>
                            <td>
                                @Model.TestExceptionDisplay[index].Exception
                                @Html.HiddenFor(model => model.TestExceptionDisplay[index].Exception)
                            </td>
                        </tr>
                           index++;
                        }
                    }
                </table>
            </div>
        </div>



        @Html.HiddenFor(model => model.MaxReplicateId)
        @Html.HiddenFor(model => model.MinReplicateId)
        @Html.HiddenFor(model => model.OutputFileName)
        @Html.HiddenFor(model => model.OutputStoredFileName)
        @Html.HiddenFor(model => model.LoadListFileName)
        @Html.HiddenFor(model => model.LoadListStoredFileName)
        @Html.HiddenFor(model => model.MinTestCompletionDate)
        @Html.HiddenFor(model => model.MaxTestCompletionDate)
@*  @Html.HiddenFor(model => model.RunLogEntryTestExceptionDisplay)*@


        <div class="bodyContent">
            <span class="leftContent"></span><span class="rightContent">
                <button name="submit" class="art-button" type="submit" value="Create">
                    Create</button></span>
        </div>
    }
</fieldset>
<script src="@Url.Content("~/Scripts/exitCode.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/exitCode.js")" type="text/javascript"></script>
<div id="treeview" title="Dialog Title" style="font-size: 10px; font-weight: normal;
    overflow: scroll; width: 800px; height: 450px;">
    <div id="errorCodes">
        @Html.RenderTree(CacheHelper.ErrorCodes(), ec => ec.Name, ec => ec.Children.ToList(), ec => (ec.ID).ToString(), null, "e")
    </div>
    <div id="inputReps" style="display: none;">
    </div>
</div>
公共类RunLogEntryTestExceptionDisplay
{
公共字符串异常{get;set;}
}

@模型RunLog.Domain.Entities.RunLogEntry @{ ViewBag.Title=“创建”; Layout=“~/Views/Shared/_Layout.cshtml”; } var runlogListErrorsUrl='@Url.Action(“ListErrorCodes”,“RunLogEntry”); var runlogTestExceptionUrl='@Url.Action(“ListTestExceptions”,“RunLogEntry”); 输入新的运行日志条目 @使用(Html.BeginForm(“Create”、“RunLogEntry”、FormMethod.Post、new{enctype=“multipart/formdata”})) { @Html.ValidationSummary(true) @(ViewBag.ErrorMessage) 加载列表文件(选择): if(Model.LoadListStoredFileName!=null) { 所附装载清单: @ActionLink(Model.LoadListFileName,“下载”,新的{@file=Model.LoadListStoredFileName}) } 输出文件(选择): if(Model.OutputStoredFileName!=null) { 附加输出: @ActionLink(Model.OutputFileName,“下载”,新的{@file=Model.OutputStoredFileName}) } 导入文件: 上传 去除 @Html.Label(“运算符”) @DropDownList(“OperatorID”,String.Empty) @Html.Label(“运行ID”) [生成] @Html.Label(“运行开始日期/时间”) @EditorFor(model=>model.RunDate) @Html.DropDownList(“小时”,ListHelpers.HourList()) : @Html.DropDownList(“分钟”,ListHelpers.Minute15List()) @Html.DropDownList(“AMPM”,ListHelpers.AMPMList()) @Html.Label(“系统”) @DropDownList(“SystemID”,String.Empty) @Html.Label(“运行类型”) @DropDownList(“RunTypeID”,String.Empty) @Html.Label(“运行说明”) @Html.TextAreaFor(model=>model.RunDescription,新{style=“width:600px;height=30px”}) @Html.Label(“分析性能问题”) @Html.DropDownList(“分析性能问题1”,ListHelpers.YesNoList()) @Html.标签(“要求的测试/周期”) @EditorFor(model=>model.SPTestsRequested) @Html.Label(“测试/周期完成”) @EditorFor(model=>model.SPTestsCompleted) @标签(“运行状态”) @DropDownList(“RunStatusID”,String.Empty) @Html.Label(“化验”) @Html.ListBoxFor(model=>model.selectedassayds,新的MultiSelectList(RunLog.Domain.Lists.GlobalList.analystItems(),“ID”,“Name”,model.selectedassayds)) @标签(“错误代码”) 点击 此处选择错误代码
@(型号说明) @Html.HiddenFor(model=>model.ErrorDescription) @标签(“测试异常”) 单击此处查看测试异常
@Html.Label(“服务输入请求”) @Html.DropDownList(“ServiceRequest”,ListHelpers.YesNoList()) @标签(“问题描述”) @text区域(“ProblemDescription”,新{style=“宽度:600px;高度:30px”}) @如果(Model.ExitCode==“1”) { @隐藏(“ExitCode”,Model.ExitCode) } 其他的 { }

异常字符串 评论 @{var index=0;} @如果(Model.TestExceptionDisplay!=nu