c# - show distinct item in a dropdownlistfor in mvc -


i using following code bind dropdownlist. foliodividentlist can have multiple values. want bind unique values not able wrong please help.

@html.dropdownlistfor(model => model.buymorelist[i].foliono, new selectlist(model.buymorelist[i].foliodividendlist.select(x =>     new selectlistitem     {         value = x.foliono.tostring(),         text = x.foliono     }).distinct(), "value", "text") 

try this:-

@html.dropdownlistfor(model => model.buymorelist[i].foliono, new selectlist(model.buymorelist[i].foliodividendlist.groupby(x => x.foliono)                     .select(x =>                        {                            var firstset = x.first();                            return new selectlistitem                            {                                value = firstset.foliono.tostring(),                                text = firstset.foliono                            };                         }                ),"value", "text") 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -