Hello.
I'm using VS2010, MVC 3, Razor and Entity Framework 4.
I want to have a drop down list with list of all countries from the Countries table. And in my model, I have just a single country id (Guid).
So, in my Model, I have:In my Controller, I have:Code:public Guid? CountryID { get; set; }And in my View, I have:Code:ViewBag.Countries = from e in new MyEntities().Countries select e;If I choose something or not, i get the "Value cannot be null", on the View line of the code (@Html.DropDown...). What am I doing wrong?Code:@Html.DropDownListFor(m => m.CountryID, new SelectList(ViewBag.Countries, "CountryID", "Name"), "")
Also, cause I'm totally new to MVC and Entity Framework, is there a better way to achieve this? I'm Googling this for few hours now with no results...
EDIT: I have just seen I've posted in the wrong forum section, so please, redirect this. Sorry.




Reply With Quote