Pull Down Menu Values

Dean Everhart 1,541 Reputation points
2023-03-28T14:45:16.65+00:00

Premise:

Enrollment Create displays and enters the CourseID and StudentID values.

User's image

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

User's image

Create View

User's image

Developer technologies ASP.NET ASP.NET Core
Developer technologies ASP.NET Other
0 comments No comments
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2023-03-28T15:10:15.7766667+00:00

    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


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.