我试图引用一个看起来像这个
的对象的下拉列表public virtual List<Administrator> AuthorizedAdministrators { get; set; }
public int SelectedAuthorizedAdministrators { get; set; }
我这样引用:
@Html.DropDownListFor(model => model.SelectedAuthorizedAdministrators, new
SelectList(Model.AuthorizedAdministrators.Select(x => new { Value = x.Id, Text = x.Username }),
"Value", "Text"), Model.SelectedAuthorizedAdministrators)
我得到的错误是
c:\STI\Portals\STI.Network.Web\Views\FinancialInstitutions\Create.cshtml(102): error CS0012:
The type 'System.Collections.Generic.List`1<T0>' is defined in an assembly that is not
referenced. You must add a reference to assembly 'System.Collections,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
如何解决此错误?我在我看来是否正确引用了这个模型?
答案 0 :(得分:0)
请尝试如下,我认为它可以帮到你。
请将下面的下拉代码更改为简单
@Html.DropDownListFor(m => m.SelectedAuthorizedAdministrators, new SelectList(Model.AuthorizedAdministrators, "Id", "Username "))