This is my controller
[AllowAnonymous]
public ActionResult Register()
{
ViewBag.Name = new SelectList(context.Roles.ToList(), "Name", "Name");
return View();
}
This is my Create view part
<div class="form-group">
@Html.Label("Select Your User Type", new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@*@Html.DropDownList("Name")*@
@Html.DropDownList("Name",(SelectList)ViewBag.Name )
</div>
</div>
i can load the form with drop down. but when I am try to save the record it gives an error "The ViewData item that has the key 'Name' is of type 'System.String' but must be of type 'IEnumerable'."