DropDownListFor MVC : How to make it work
My model is:
public string Vehicle
public DropDownListModel()
{
List<SelectListItem> items = new List<SelectListItem>();
items.Add(new SelectListItem() { Text = "one", Value = "one" });
items.Add(new SelectListItem() { Text = "two", Value = "two" });
SelectList items2 = new SelectList(items);
}
{
get;
set;
}
public SelectList VehicleList
{
get;
set;
}
}
I am want to render selectList into a dropdwonlist but what I am getting is
My View is this:
@using ( Html.BeginForm("Post","Guestbook"))
{
@Html.Label("Name") @Html.DropDownListFor(m=>
m.Vehicle,Model.VehicleList)<br />
<input type="submit" name="submit" value="submit" />
}
What am I doing wrong. I have spend quite a bit of time on this and
checked various SO question but could not resolve this.
No comments:
Post a Comment