The <select> only supports a value and text. So you could show the title
ViewData[“CourseID”] = new SelectList(_context.Courses,”CourseID”,”Title”);
if you want a multi column drop-down you will need to pick a JavaScript control
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Premise:
Enrollment Create displays and enters the CourseID and StudentID values.
How do I program the pull down menus to display Course Title and Student FirstName LastName rather than the ID properties (but still enter the corresponding ID values required)?
GitHub: https://github.com/DeanEverhart/ContosoUniversity1
Tutorial: https://learn.microsoft.com/en-us/aspnet/core/data/ef-mvc/intro?view=aspnetcore-6.0
Environment: Net Core 6, Visual Studio Community 2022 (64 bit), WIndows 11
Controller
Create View
The <select> only supports a value and text. So you could show the title
ViewData[“CourseID”] = new SelectList(_context.Courses,”CourseID”,”Title”);
if you want a multi column drop-down you will need to pick a JavaScript control