SelectListItem with data-attributes

后端 未结 5 2088
温柔的废话
温柔的废话 2020-11-29 01:59

Is there anyway to have a SelectList prepopulated on ViewModel with data-attributes ?

I want to do

@Html.DropdownListFor(m=> m.CityId, Model.Citi         


        
5条回答
  •  粉色の甜心
    2020-11-29 02:42

    You'll have to extend SelectListItem, and then extend DropDownListFor to use the extended SelectListItem.

    Have a look at this solution:

    Adding html class tag under

提交回复
热议问题