First off, I have been searching for an answer for this and come up with solutions for it, but not matching my exact question regarding automatic generation of dropdownlists (just HOW to make one yourself).
So, the question is. I like to use the scaffolding option in Visual Studio, since it sets up a controller with full CRUD and views that meets my needs.
However, I just ran into a situation where I would like to have a dropdownlist. Is this something that the Scaffolding can create? Or is it in fact something that I have to do myself?
For example I have this model:
public class School
{
public int SchoolID { get; set; }
[Required(ErrorMessage = "A value has to be entered.")]
[StringLength(200)]
public string Name { get; set; }
[Required(ErrorMessage = "A value has to be entered.")]
[StringLength(200)]
public string MailPrefix { get; set; }
public int CountryID { get; set; }
public virtual List<Country> Country { get; set; }
}
So what I am trying to figure out here is what needs to be done to make Visual Studio realize that i want a Dropdownlist created, making it possible to select country, and then save that countryId to the database.
I should point out that I'm also using Entity Framework and the scaffolding option for that in Visual Studio.
Thanks a lot in advance for any info!