In your editor template you seem to be using some ViewData["Items"]
property which you never set. If you want to use such property make sure you have assigned it:
@Html.EditorFor(
model => model.FaultTypeID,
"RadioButtonList",
new { Items = new SelectList(Model.AllowdeFaultTypes, "FaultTypeID", "FaultTypeName") }
)
This being said, your approach with using some ViewData stuff seems totally wrong to me.
I would simply define a view model (as always in ASP.NET MVC):
public class RadioListViewModel
{
public string Value { get; set; }
public IEnumerable<SelectListItem> Values { get; set; }
}
and then you could have your editor template strongly typed to this view model. Of course your editor template will be now stored in ~/Views/Shared/EditorTemplates/RadioListViewModel.cshtml
:
@model IRadioListViewModel
@foreach (var item in Model)
{
<a>@item.Text</a> <b>@item.Value</b>
}
and now all that's left is to use this view model in your main view model:
public class MyViewModel
{
public RadioListViewModel FaultTypes { get; set; }
...
}
and then inside your view simply render the corresponding editor template:
@model MyViewModel
...
@Html.EditorFor(x => x.FaultTypes)
Simple, conventional, strongly typed.