Hi everyone,
I am beginning in this issue MVC 2 I hope you can help me. I created a basic model
public class RegisterModel
{
public string Name { get; set; }
public int idCountry { get; set; }
public string Country { get; set; }
}
And I have in the controller the following
public ActionResult Register()
ViewData["country"] = new SelectList(db.PAIS.ToList(), "ID_PAIS", "DESC_PAIS");
return View();
}
My view
<div class="editor-field">
<%= Html.DropDownList("country")%>
</div>
but when I want save on the data base show me a error
[HttpPost]
public ActionResult Register(RegisterModel model)
{
USUARIO usuario = new USUARIO()
{
name = model.name,
city = model.city // show me a error
}
}
Could you please tell me how to save in the data base from this parameters from dropdownlist in my aplication.