I am trying to create a drop down list using asp.net mvc.
Model:
public string Status { get; set; }
public List<SelectListItem> StatusList { get; set; }
public AddUser()
{
StatusList = new List<SelectListItem>
{
new SelectListItem{Value = "0",Text = "0"},
new SelectListItem{Value = "1",Text = "1"}
};
}
View:
<%: Html.DropDownListFor(m=>m.Status,new SelectList(Model.StatusList,"Value","Text")) %>
<%: Html.ValidationMessageFor(m => m.Status) %>
I don't know why but I keep getting this error:
Object reference not set to an instance of an object.
Anyone knows what I am doing wrong?