refreshing an EnumDropDownListFor MVC5

on my view I have:

@Html.EnumDropDownListFor(model => model.SelectedSchemeJoinerReportType)

In the model I have:

[DisplayName("Provider : ")]
public List<SchemeJoinersReportTypeList> SchemeJoinerReportTypes { get; set; }

[DisplayName("Provider : ")]
public SchemeJoinersReportTypeList? SelectedSchemeJoinerReportType { get; set; }

When the view initially renders the dropdown is correctly populated with the values that I expect.

On a form submit, I pass the model but as we know it doesn’t pass the items in the dropdown, So in Debug the list is empty on the controller. After I have done some stuff, I return back to the same view, but because my list is no longer populated it crashes.

SchemeJoinersReportTypeList is declared as an Enum.

how do I reset my list before returning the model

billcrawley

On a form submit, I pass the model but as we know it doesn’t pass the items in the dropdown,

SO reload as in the GET action.

Leave a Reply