Hello,
I'm new to ASP.NET MVC. I'm trying to figure out how create a basic drop down list from values in my database. In ASP.NET web forms, I know I can load a drop down list like this:
Page.aspx
<asp:DropDownList ID="myDropDownList" runat="server" DataTextField="FullName" DataValueField="ID" OnLoad="myDropDownList_Load" />
Page.aspx.cs
void myDropDownList_Load(object sender, EventArgs e)
{
if (Page.IsPostBack == false)
{
List<Person> people = GetPeopleFromDatabase();
myDropDownList.DataSource = people;
myDropDownList.DataBind();
}
}
How do I do the same type of thing in ASP.NET MVC? Thank you!