asp.net - EnumDropDownList MVC 5 -


i have class

public partial class team {     public int id { get; set; }     public shifts shift { get; set; } }  public enum shifts : int {     first = 1,     second = 2 } 

and mvc view code

    <div class="form-group">         @html.labelfor(model => model.shift, htmlattributes: new { @class = "control-label col-md-2" })         <div class="col-md-10">             @html.enumdropdownlistfor(model => model.shift, htmlattributes: new { @class = "form-control" })             @html.validationmessagefor(model => model.shift, "", new { @class = "text-danger" })         </div>     </div> 

and controller post code...

    public actionresult create([bind(include = "shift")] team team)     {         if (modelstate.isvalid)         {             db.teamset.add(team);             db.savechanges();             return redirecttoaction("index");         }          return view(team);     } 

in db, shift int type , i'm trying values enum, in post form text ("first" or "second"). tried find documentation enumdropdownlistfor without success, if have idea i'll thankful..

public enum shifts : int {  [display(name = "first")] first = 1,  [display(name = "second")] second = 2 } 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -