C# 我的DropDownListFor仅显示回邮错误
我的DropDownList用于正确显示数据,但当我转到HttpPost时,会显示错误System.NullReferenceException 我的viewModel:C# 我的DropDownListFor仅显示回邮错误,c#,asp.net-mvc,razor,html.dropdownlistfor,C#,Asp.net Mvc,Razor,Html.dropdownlistfor,我的DropDownList用于正确显示数据,但当我转到HttpPost时,会显示错误System.NullReferenceException 我的viewModel: public class contaModel { public SelectList responsaveis { get; set; } public List<int> idResponsaveis { get; set; } public Selec
public class contaModel
{
public SelectList responsaveis { get; set; }
public List<int> idResponsaveis { get; set; }
public SelectList responsaveisCartao { get; set; }
public List<int> idResponsaveisCartao { get; set; }
}
生成错误的行:
@Html.DropDownListFor(x => x.idResponsaveis, Model.responsaveis)
我之所以使用列表,是因为我在页面中使用了多个下拉列表。您在回发时具体做了什么?我有一个按钮,可以根据用户的需要复制下拉列表的节点,返回的是所选ID的列表,所以使用列表。通过这些ID,我将银行的元素与负责卡的元素联系起来。
@Html.DropDownListFor(x => x.idResponsaveis, Model.responsaveis)