I have a table with about 3 items. I wish to populate the Dropdown List using that table. But i have a condition that i want to show only 2 items in the Dropdown List. How can it be done?
I have a table with about 3 items. I wish to populate the Dropdown
Share
You could use a view model:
and then take the first 2 items (obviously if your requirements is to take some other 2 items based on some condition you could chain with the
.Where()extension method in order to filter first before calling.Take()):The view is standard stuff, simply call to the DropDownListFor helper: