model view controller - Use of distinct() in dropdownlistFor -



model view controller - Use of distinct() in dropdownlistFor -

i trying utilize distinct() in dropdownlistfor in order rid of duplicates. model.categories contains list of strings. been trying different "combinations" cant work..i thought below illustration tric still shows duplicates.

@html.dropdownlistfor(model => model.catdroptemp, model.categories.select(kat => new selectlistitem { text = kat, value = kat }).distinct())

do maybe have alter whole construction of list or there im missing?

edit:

found syntax here @ forum:

@html.dropdownlist( "foo", new selectlist( model.categories.select(x => new { value = x, text = x }).distinct(), "value", "text" ) )

that takes care of distinct()-part, however...with syntax cant see add together my

new{@class="form-control"}

any tips on maybe?

i think need distinct before in chain, doesn't selectlistitem implements equality/comparison interfaces (assuming model overrides equals , gethashcode)

model-view-controller dropdownlistfor

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -