[英]The best overload for List issue
@Html.DropDownList(expression: model => model.CategoryID,
new List<SelectListItem>(Model.CategorySelectListItem, dataValueField: "Value",
dataTextField: "Text"),htmlAttributes:new {@class = "form-control"})
This is my code, what does the error mean and how do I fix it?这是我的代码,错误是什么意思,我该如何解决?
What you need is a new instance of SelectList
actually not a List of SelectListItem
, change your code like this and it works fine:您需要的是
SelectList
SelectListItem
List ,像这样更改您的代码,它可以正常工作:
@Html.DropDownList(expression: model => model.CategoryID,
new SelectList(Model.CategorySelectListItem, dataValueField: "Value",
dataTextField: "Text"),htmlAttributes:new {@class = "form-control"})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.