I have a Vote class and one of the properties it can have is a vote type. Such as unanimous, a 3/4 vote, a simply majority, etc. Each type needs to have a string associated with
Since you have the type
and description
I'll better suggest you to create a class
that wraps up both instead of enum
. The advantage is you can reduce more work and it's very flexible.
public class VoteType
{
public string Name{ get; set; }
public string Description{ get; set; }
}
Now your Vote
class will have reference to this VoteType
.
public class Vote
{
...
public VoteType Type{ get; set; }
}
In your VoteViewModel
you better have a class that contains all the VoteType
s.
public class VoteViewModel
{
...
public IEnumerable VoteTypes{ get; set; }
}
Now you can easily bind the VoteTypes
in a dropdownlist.
@model VoteViewModel
@Html.DropDiwnListFor(m => m.VoteTypes,...)