EDUDOTNET

Monday, April 29, 2013

ASP.NET MVC: DROPDOWNLIST WITH ENUM




Create Drop-down list with enum values in MVC:




Inside model we need to define:
    1. a property of enum type.
    2. a property of SelectedListItem as IEnumerable.
    3. Inside constructor filling Dropdown list from enum.
ASP.NET MVC: DROPDOWNLIST WITH ENUM
Model
Enum (County list):
ASP.NET MVC: DROPDOWNLIST WITH ENUM
Enum

Action (Creating object of model and return model):
ASP.NET MVC: DROPDOWNLIST WITH ENUM
Action

View (Calling mode on top and filling dropdown list)
ASP.NET MVC: DROPDOWNLIST WITH ENUM
View







1 comments: