'How can I connect the COMBOBOX to a table?

enter image description hereI am a programmer at entityframeworkcore mvc. Hey,I am a programmer at entityframeworkcore mvc. Hey,I am a programmer at entityframeworkcore mvc.

I work with sqlserver database,I want to select a category from comboBox and to see a table with all the information about the category

My View:

    <section>
    <div>
    <label>Please select a category:</label>
    <select asp-items="ViewBag.CategoryId" class="selectItem"></select>
    </div>
    </section>

    <section>
<table class="table">
    <thead>
        <tr>
            <th>Portrait</th>
            <th>
                @Html.DisplayNameFor(model => model.Name)
            </th>
            <th>Find out more and comment</th>
        </tr>
    </thead>
    <tbody>
   @foreach (var item in Model!) {
       <tr>
            <td>
               @Model.Where(c => c.AnimalId == c.CategoryId).ToList().;
           </td>
         <td>
               @Html.DisplayFor(modelItem => item.Name)
           </td>
            <td>
                <input type="submit" value="Detail" asp-action="Details">
            </td>
        </tr>
    }  ``` 


MyController:
```        private readonly IRepository<Category> _repo;
        private readonly IAnimalRepository _repoAni;


        public CatalogController(IRepository<Category> repo, IAnimalRepository repoAni)
        {
            _repo = repo;
            _repoAni = repoAni;
        }

        [HttpGet]
        public IActionResult DisplayAnimals()
        {
            ViewBag.CategoryId = new SelectList(_repo.Get(), "CategoryId", "Name");
            return View();
        }

        [HttpPost]
        public async Task<IActionResult> Details(int? id)
        {
            var animal = await _repoAni.Addd() // return _context.Animals
            .Include(a => a.Category)
            .FirstOrDefaultAsync(m => m.CategoryId == id);
            return View(animal);
        }




Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source