I have been searching around for almost 3 days to find a solution to the following problem.
I'm simply trying to add a DropDownList in RegisterViewModel (Identity).
During user registration I need to prompt for the Gender.
I have already inserted the following items in the table.
Code = F
Definition = Female
-------------------
Code = M
Definition = Male
When I generate the DropDownList directly inside GenderDDController and it's view it works perfectly but as soon as I'm in RegisterViewModel I have zero chance due to I can't reference multiple models in Register.cshtml (View).
I should also indicate that I'm new to MVC and I'm sure that's the only reason that I look confused right now.
GenderDD | Model
public partial class GenderDD
{
public int Id { get; set; }
[StringLength(1)]
public string Code { get; set; }
[StringLength(50)]
public string Definition { get; set; }
public DateTime? CreateDate { get; set; }
[StringLength(50)]
public string CreatedBy { get; set; }
public bool Deleted { get; set; }
public DateTime? UpdateDate { get; set; }
[StringLength(50)]
public string UpdatedBy { get; set; }
}
RegisterViewModel | Controller
[AllowAnonymous]
public ActionResult Register()
{
ViewData["GenderList"] =
Enum.GetValues(typeof (GenderDD))
.Cast<GenderDD>()
.Select(c => new SelectListItem {Text = c.ToString(), Value = c.ToString()});
return View();
}
RegisterViewModelSelectListproperty inRegisterViewModel, then you can use it in the View