ASP.NET MVC 5始终显示表中的第一行

时间:2018-02-21 06:43:01

标签: asp.net-mvc asp.net-mvc-4

我有一个上传csv文件并显示详细信息行的Web应用程序。

在第一个视图中我创建了一个表,我需要选择几行,然后在动作控制器中我做一些工作人员并返回到第二个视图,然后在那里创建一个包含第一个视图中所选行的表。

现在如果我在第一个视图中选择行1,3,5,我会进入第二个视图 行1,2,3或在第一个视图中我选择4,6在第二个视图中我得到1,2。

if (oldVersion == 2) {
   RealmObjectSchema personSchema = schema.get("ClassName");
   personSchema.setNullable("nullableFielName", true);
}

ViewModelForExcel类始终包含最新列表。

Message.objects.filter(recipient__user__username__in=['billy'])

争吵: 第一:

public class DetailsExcelFile
{        
    public int NumberClient { get; set; }        
    public string NameClient { get; set; }
    public int Amount { get; set; }
    public string Email { get; set; }
    public string ContactPerson { get; set; }
    public bool IsSelectedRow { get; set; }
    public bool NeedEmail { get; set; }
}

控制器中的操作:

public class ViewModelForExcel
{
    public List<DetailsExcelFile> DetailsExcelFileList { get; set; }
    public DetailsExcelFile ObjectDetailsExcelFile { get; } = new DetailsExcelFile();
    public ViewModelForExcel()
    {

    }
}

第二个视图:(UpdateFileDetails.cshtml)

@model SendLinks.ViewModels.ViewModelForExcel
@{
    ViewBag.Title = "FileDetails";
    Layout = "~/Views/Shared/_Layout.cshtml";
}



@using (Html.BeginForm("ChooseItems", "Home", FormMethod.Post))
{

    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)
    if (@ViewBag.Message != null)
    {
        <div style="border: 1px solid red">
            @ViewBag.Message
        </div>
    }

    <table id="DetailsExcelChoose" class="table-responsive text-right">
        <thead>
            <tr>
                <th><input type="checkbox" id="checkAll" /></th>
                <th class="RightToLeft">@Html.LabelFor(a => a.ObjectDetailsExcelFile.IndexRow, new { @readonly = "readonly" })</th>
                <th class="RightToLeft">@Html.LabelFor(a => a.ObjectDetailsExcelFile.InvoiceNumber, new { @readonly = "readonly" })</th>
                <th class="RightToLeft">@Html.LabelFor(a => a.ObjectDetailsExcelFile.NumberClient, new { @readonly = "readonly" })</th>
                <th class="RightToLeft">@Html.LabelFor(a => a.ObjectDetailsExcelFile.NameClient, new { @readonly = "readonly" })</th>
                <th class="RightToLeft">@Html.LabelFor(a => a.ObjectDetailsExcelFile.Amount, new { @readonly = "readonly" })</th>
                <th class="RightToLeft">@Html.LabelFor(a => a.ObjectDetailsExcelFile.ContactPerson, new { @readonly = "readonly" })</th>
            </tr>
        </thead>
        <tbody>
            @for (var i = 0; i < Model.DetailsExcelFileList.Count(); i++)
            {
                <tr>
                    <td>@Html.CheckBoxFor(a => a.DetailsExcelFileList[i].IsSelectedRow, true)</td>
                    <td>@Html.TextBoxFor(a => a.DetailsExcelFileList[i].IndexRow, new { @class = "wideIndexRow" })</td>
                    <td>@Html.TextBoxFor(a => a.DetailsExcelFileList[i].InvoiceNumber)</td>
                    <td>@Html.TextBoxFor(a => a.DetailsExcelFileList[i].NumberClient, new { @class = "wideIndexRow" })</td>
                    <td>@Html.TextBoxFor(a => a.DetailsExcelFileList[i].NameClient)</td>
                    <td>@Html.TextBoxFor(a => a.DetailsExcelFileList[i].Amount, new { @class = "wideIndexRow" })</td>
                    <td>@Html.TextBoxFor(a => a.DetailsExcelFileList[i].ContactPerson)</td>
                </tr>
            }
        </tbody>
        <tr>
            <td></td>
            <td>
                <input type="submit" value="choose" />
            </td>
            <td></td>
        </tr>
    </table>
}

我尝试调试我在控制器中执行的所有操作,一切正常。只是视图出问题。

更新问题

0 个答案:

没有答案