@Html.DropDownListFor; How to set different background color for each item in DDL?

前端 未结 2 1709
遥遥无期
遥遥无期 2021-01-22 07:35

I have a dropdown list (@html.DropDownListFor) wherein I am showing name of colors... I want to display each item having seperate background color.. Like, an item \"Green\" shou

2条回答
  •  死守一世寂寞
    2021-01-22 08:15

    Don't forget that you can always write old fashioned HTML in a view (OMG!).

    But, if you are using the code in multiple places, then write a helper that extends DropDownListFor to create your select with styling. If you are using it once, you can simply write something like:

    
    

提交回复
热议问题