DropDownListForModel Can't add HTML attributes
Clash Royale CLAN TAG#URR8PPP
DropDownListForModel Can't add HTML attributes
I am trying to add html attributes to this drop down list like this:
@Html.DropDownListForModel(p => p.PreviousCompanyCompletedMappingId, Model.PreviousCompanyMappings.ToSelectListItems(), new @class = "dropdown" )
But I am getting error: Argument 4: cannot convert from '<anonymous type: string class>' to 'string'
Argument 4: cannot convert from '<anonymous type: string class>' to 'string'
1 Answer
1
The compiler has a problem identifying the correct method overload to use. Explicitly specify null
for the optionLabel
parameter.
null
optionLabel
@Html.DropDownListForModel(p => p.PreviousCompanyCompletedMappingId, Model.PreviousCompanyMappings.ToSelectListItems(), null, new @class = "dropdown" )
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Could you show code for DropDownListForModel method?
– Tomato32
Aug 6 at 14:32