1

DropDownList にクラスを追加して、見栄えを良くする必要があります。したがって、私は以下のコードを使用していますhtmlAttribute:

@Html.DropDownList("DepartmentId", "Select a Department:", htmlAttributes: new { @class = "form-control" })

次のように表示されているため、エラーが発生します。

does not contain a definition for 'DropDownList' and the best extension method overload 'System.Web.Mvc.Html.SelectExtensions.DropDownList(System.Web.Mvc.HtmlHelper, string, System.Collections.Generic.IEnumerable<System.Web.Mvc.SelectListItem>, string)' has some invalid arguments

フォーム コントロール クラスを追加して DropDownList を実行する方法を教えてもらえますか?

動作しているコード:

@Html.DropDownList("DepartmentId", null, htmlAttributes: new { @class = "form-control" })
4

1 に答える 1