c# - How to retain spaces in DropDownList - ASP.net MVC Razor views -


i'm binding model in following way in view:

<%=html.dropdownlist("selecteditem",new selectlist(model.myitems,"itemid","itemname")) %> 

issue item text formatted text spaces in between words, below.

#123  first          $234.00 #123  anotheritem    $234.00 #123  second         $234.00 

i want retain spaces in item text after added dropdownlist. unfortunately dropdownlist shows them without spaces below:

#123 first $234.00 #123 anotheritem $234.00 #123 second $234.00 

when view source of page spaces intact in display not. i've tried add '&nbsp;' instead of spaces selectlist (mvc framework class) internal method using htmlencode before adding them items in dropdownlist.

is there way can achieve this?

nbsp in html corresponds "\xa0" c# string, use instead of spaces, when html encoded produce nbsp


Comments