部分视图和公共财产混淆

时间:2018-10-01 07:26:17

标签: c# razor

我有以下模型:

public class CitationViewModel
{
    public long Id { get; set; }

    public GeneralModel GeneralInfo { get; set; }

    public List<TransportModel> Transport { get; set; }

    public List<SelectItem> PricingList { get; set; }
}

在我的GeneralModel中,我有:

public class GeneralModel
{
    public long Id { get; set; }
    public long? PricingMethod { get; set; }
}

和TransportModel:

public class TransportModel
{
    public long ModeOfTransportId { get; set; }

    public DocumentModel Document { get; set; }
}

在我的控制器中,我正在执行以下操作:

public ActionResult Index(long leadID)
{
    CitationViewModel citation = new CitationViewModel
    {
        GeneralInfo = setting the general info details.
    };
    citation.LeadId = leadID;
    citation.PricingList = GetPricingList();

    citation.Transport = GetModeOfTransport();


    foreach (TransportModel trans in citation.Transport)
    {
        //Load Document Types
        DocumentModel document = new DocumentModel();
        trans.Document = document;
    }


    return View(citation);
}

在我看来,我正在为TransportModel做一个循环:

@for(var i = 0; i < Model.Transport.Count; i++)
{
    <div class="custom-file">
        @Html.Partial("../Shared/Partials/Documents/_UploadDocument", Model.Transport[i].Document)
    </div>

    <div class="mdl-textfield mdl-textfield--floating-label js-dropdown">
        @Html.EJ().DropDownListFor(model => model.GeneralInfo.PricingMethod).Datasource(Model.PricingMethodList).DropDownListFields(Pricing => Pricing.Text("Value").Value("Key")).EnableFilterSearch(true).FilterType(SearchFilterType.Contains).PopupHeight("300px")
        <label for="PricingMethod">PricingMethod</label>
    </div>

}

但是,对于我拥有的每种运输方式,我都没有得到要显示的定价列表和局部视图。 实际上,对于每种运输方式,我都会显示一个选项卡,并且在每个选项卡中,我都需要具有“定价”下拉菜单,并且每个调用都需要有一个UploadDocument部分视图。 我现在得到的结果是这两个属性混杂在一起。 知道我在这里可能做错了什么吗? 谢谢

0 个答案:

没有答案