0
    [AllowAnonymous]
    public ActionResult Register()
    {
      ViewBag.roleList = DALUser.GetRoleList();
      ViewBag.stateList = DALUser.GetStateList();
      return View();
    }

<li>
    @Html.LabelFor(m => m.role)
    @Html.DropDownListFor(m => m.role, new SelectList(ViewBag.roleList, "Select Role"))
</li> 

原因となる

「値を null にすることはできません。パラメータ名: items」. roleList と stateList は単なる文字列リストです

誰でもこれについて考えがありますか?

4

1 に答える 1

1

一般に、SelectListコンストラクターに null 値を指定すると、そのエラーが表示されます。ViewBag.roleList = DALUser.GetRoleList();ブレークポイントを設定し、以外のものnullが返されていることを確認する必要があります。IListオブジェクトのデフォルト値は ですnull

于 2013-05-15T07:15:57.623 に答える