Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

asp.net core select tag helper

$
0
0

Hi, I'm having trouble with the select tag helper. I am able to retrieve records from the database and populate my select tags with the correct value/text for all available options but when submitting my form no values are being returned and I am not sure what I am doing wrong. Any help would be greatly appreciated. My code is below. Thank you.

Model 1:

public class Basis
    {
        public int BasisId { get; set; }
        public string BasisName { get; set; }
    }

Model 2: 

public class Category
    {
        public string CategoryId { get; set; }
        public string CategoryName { get; set; }
    }

ViewModel:

public class SearchManager
    {
        public List<Basis> Basis { get; set; }

        public List<Category> Category { get; set; }
 {

View:

<select id="basisSelect" multiple="multiple" asp-for="Basis" asp-items="@(new SelectList(Model.Basis, "BasisId", "BasisName"))"></select><select id="categorySelect" asp-for="Category" asp-items="@(new SelectList(Model.Category, "CategoryId", "CategoryName"))"></select>

Controller:

[HttpPost]
public IActionResult SubmitSearch(SearchManager criteriaManager)
{}

When I make a selection I get a count of zero. As shown in the image.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>