Answer the question
In order to leave comments, you need to log in
How to display a list from a database in ASP NET Core?
There is a Player class in which
Id, Name, Age, Gender, Team
In Team:
Id, Name
On the add page there is a Player model (for the form)
But you also need to display it in all Team values (to select accordingly)
foreach (var item in Model.Team)
{
<option value="@item.Id">@item.Name</option>
}
Answer the question
In order to leave comments, you need to log in
ViewData or ViewBag to help you, just in case you pass a lot of data to the model
The model can be any class for your needs, you can encapsulate any necessary subclasses in your model.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question