This thread is kind of old but since it still came up in the search results:
If the name of your property is ePriority and PriorityEnum is an enum, then the following code will give you you all enum values in the drop down and bind correctly to your model:
Sadly this didn't work for me, it didn't prefill the drop down with the correct setting of the model (in the case of an edit). Anyone have a suggestion why?
1 Answer, 1 is accepted
0
Nencho
Telerik team
answered on 18 Jan 2018, 08:50 AM
Hello Chris,
If I had correctly understood the issue that you are experiencing - the value is not correctly set when the DropDownListFor helper is used. If that's correct, I would suggest you to refer to the forum thread where a cause/solution for this case is discussed:
If the name of your property is ePriority and PriorityEnum is an enum, then the following code will give you you all enum values in the drop down and bind correctly to your model:
Html.Kendo().DropDownList()
.Name(
"ePriority"
)
.BindTo(Enum.GetNames(
typeof
(PriorityEnum)).ToList()
This is equivalent to the following vanilla ASP.NET code (in function, not in the HTML it produces):
Html.DropDownListFor(m => m.ePriority,
new
SelectList(Enum.GetNames(
typeof
(PriorityEnum))))