【问题标题】:getting error using partial view(@Html.Partial("SchemeDetails")) System.Collections.Generic.IEnumerable`1[MutualFund.Models.SchemeClass]'使用局部视图出错(@Html.Partial("SchemeDetails")) System.Collections.Generic.IEnumerable`1[MutualFund.Models.SchemeClass]'
【发布时间】:2020-07-24 06:57:19
【问题描述】:

在 index.cshtml 中,我使用局部视图添加了 SchemeDetails.cshtml,通过

@Html.Partial("SchemeDetails")

我收到此错误:model item passed into the dictionary is of type 'System.Collections.Generic.List...

以下是这些错误的截图:

Screenshot 1

Screenshot 2

【问题讨论】:

    标签: asp.net-mvc asp.net-web-api model-view-controller


    【解决方案1】:

    您将 List 元素传递给视图,但在 SchemeDetails.cshtml 中,您将模型声明为 IEnumerable。

    @model IEnumerable<MutualFund.Models.SchemeClass>
    

    你必须改变你的 InvestClass Index.cshtml 像

    @model IEnumerable<MutualFund.Models.InvestClass>
    

    【讨论】:

      猜你喜欢
      • 2014-08-18
      • 2023-03-04
      • 2011-12-31
      • 2019-06-23
      • 1970-01-01
      • 2012-01-04
      • 1970-01-01
      • 2019-08-11
      相关资源
      最近更新 更多