asp.net mvc - Drop down / SelectListItem in ViewModel MVC -


i new mvc , have been told not use selectlistitem in view untidy. advised put in model , pass view.

i have no idea whether code in model correct. assistance highly appreciated. code here:

public class zipcodemodel     {         public string zipcode { get; set; }           public static readonly             ienumerable<selectlistitem> items;          static zipcodemodel()         {             items = new list<selectlistitem>             {                 new selectlistitem {text = "a"},                 new selectlistitem {text = "b"},                 new selectlistitem {text = "c"},                 new selectlistitem {text = "d"}             };         }     } 

thanks in advance :)

try this

@html.dropdownlistfor(m => m.zipcodemodel,        new selectlist(m.audiothemes, "value", "text"), new { @class = "class" }) 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -