Hi benuklemi,
Check this example. Now please take its reference and correct your code.
Model
public class PersonModel
{
public int Id { get; set; }
public string Name { get; set; }
public string Country { get; set; }
}
Controller
public class HomeController : Controller
{
public IActionResult Index()
{
List<PersonModel> persons = new List<PersonModel>();
persons.Add(new PersonModel { Id = 1, Name = "John Hammond", Country = "United States" });
persons.Add(new PersonModel { Id = 2, Name = "Mudassar Khan", Country = "India" });
return View(persons);
}
}
View
@model List<List_Model_Core_MVC.Models.PersonModel>
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
@for (int i = 0; i < Model.Count(); i++)
{
<div class="row">
<div class="col-md-3 me-2">
<label asp-for="@Model[i].Id" class="control-label col-md"></label>
<input asp-for="@Model[i].Id" class="form-control" />
<span asp-validation-for="@Model[i].Id" class="text-danger"></span>
</div>
<div class="col-md-3 me-2">
<label asp-for="@Model[i].Name" class="control-label"></label>
<input asp-for="@Model[i].Name" class="form-control" />
<span asp-validation-for="@Model[i].Name" class="text-danger"></span>
</div>
<div class="col-md-3 me-2">
<label asp-for="@Model[i].Country" class="control-label"></label>
<input asp-for="@Model[i].Country" class="form-control" />
<span asp-validation-for="@Model[i].Country" class="text-danger"></span>
</div>
</div>
}
</div>
</body>
</html>
Screenshot