DropDownListForModel Can't add HTML attributes

The name of the pictureThe name of the pictureThe name of the pictureClash 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'





Could you show code for DropDownListForModel method?
– Tomato32
Aug 6 at 14:32




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.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS