This lightweight solution worked for my mvc5 project:
:
@{ Model.ModelItemsList.Add(new ModelItem{ }); SelectList modelItemSelectList = new SelectList(Model.ModelItemsList, "ModelItemID", "ModelItemName"); }
Just add a new item to the List<> that you want to display in your view. In my case, I added an empty "ModelItem" to my List<ModelItem> ModelItemList . Since my ModelItemID is Guid, I had to check Guid.Empty in my controller method and do some code. That's all.
PixelPlex Jun 16 '14 at 22:19 2014-06-16 22:19
source share