I have done lots of research and found that some times the name of the object can cause issues and so on. However I have (at least I think) determined that this is not an issue. Most of the issues I see people have is trying to convert enum to the dropdownlist, which I do not need.

I am using:

public enum PriorityTypeEnum
{
    Low = 1,
    Medium = 2,
    High = 3,
}

@Html.DropDownListFor(m => m.CurrentTicket.Priority, Model.PriorityList.SetSelectedItem((int)Model.CurrentTicket.Priority))

Which gets the list of all the Priorities, and sets the selected item to the CurrenTicket.Priority.

Now, the list itself that is returned is fine. The item that should be selected is, however nothing is selected in the DropDownListFor. After doing debugging if I change the type of the Priority from the enum (PriorityTypeEnum) to an int, it selects the right one. As you can tell, this is really annoying when I have an enum that holds the values.

My question is how to make it select properly and still use the enum?

I don't know if I am missing something very simple here. I have been looking at this way to long.

Related posts

Recent Viewed