title: .NET Core Razor page Dropdown not returning a value
body: <p>I'm very new to .net core 5 and razor pages and trying to build a search form to display results but am unable to get the values from two specific dropdowns(always return a 1 or null, depending on the model definition). Here is the HTML for the search controls:</p>
  <pre class="lang-html prettyprint-override"><code>    &lt;form method=&quot;post&quot;&gt;
      &lt;div class=&quot;container-fluid&quot;&gt;
          &lt;div class=&quot;row&quot;&gt;
              &lt;div class=&quot;col-sm-2 vh-100&quot; style=&quot;background-color:lightgray;&quot;&gt;
                  &lt;div class=&quot;row&quot;&gt;
                      &lt;div class=&quot;colvertspc&quot;&gt;
                          &lt;label&gt;Begin Date&lt;/label&gt;
                          &lt;input type=&quot;date&quot; class=&quot;form-control&quot; name=&quot;begindate&quot; id=&quot;begindate&quot; asp-for=&quot;paramsearch.BeginDate&quot; /&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;row&quot;&gt;
                      &lt;div class=&quot;colvertspc&quot;&gt;
                          &lt;label&gt;End Date&lt;/label&gt;
                          &lt;input type=&quot;date&quot; class=&quot;form-control&quot; name=&quot;enddate&quot; id=&quot;enddate&quot; asp-for=&quot;paramsearch.EndDate&quot; /&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;row&quot;&gt;
                      &lt;div class=&quot;colvertspc&quot;&gt;
                          &lt;label&gt;Access Rule Group&lt;/label&gt;
                          &lt;div&gt;
                              &lt;select name=&quot;accessrulegroup&quot; asp-items=&quot;Model.accessgrouplist&quot; class=&quot;form-control&quot; asp-for=&quot;paramsearch.AccessRuleGroupCode&quot;&gt;
                                 &lt;option value=&quot;-1&quot;&gt;Select&lt;/option&gt;
                              &lt;/select&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;row&quot;&gt;
                      &lt;div class=&quot;colvertspc&quot;&gt;
                          &lt;label&gt;Access Rule Category&lt;/label&gt;
                          &lt;div&gt;
                              &lt;select name=&quot;accessrulecategory&quot; asp-items=&quot;Model.accesscategorylist&quot; class=&quot;form-control&quot; asp-for=&quot;paramsearch.AccessRuleCategoryCode&quot;&gt;
                                  &lt;option value=&quot;-1&quot;&gt;Select&lt;/option&gt;
                              &lt;/select&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;row&quot;&gt;
                      &lt;div class=&quot;colvertspc&quot;&gt;
                          &lt;label&gt;Sort Order&lt;/label&gt;
                          &lt;div&gt;
                              &lt;select name=&quot;sortorder&quot; class=&quot;form-control&quot; asp-for=&quot;paramsearch.SortOrder&quot;&gt;
                                  &lt;option value=&quot;1&quot;&gt;ASC&lt;/option&gt;
                                  &lt;option value=&quot;2&quot;&gt;DESC&lt;/option&gt;
                              &lt;/select&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;row&quot;&gt;
                      &lt;div class=&quot;colvertspc&quot;&gt;
                          &lt;button type=&quot;submit&quot; class=&quot;btn btn-success&quot;&gt;SEARCH&lt;/button&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  </code></pre>
  <p>Here is the code for the PageModel to bind and retrieve values:</p>
  <pre class="lang-cs prettyprint-override"><code>        public class IndexModel : PageModel
      {
          private readonly ILogger&lt;IndexModel&gt; _logger;
  
          public IndexModel(ILogger&lt;IndexModel&gt; logger)
          {
              _logger = logger;
          }
  
  
          //dropdowns
          public SelectList accessgrouplist { get; set; }
          public SelectList accesscategorylist { get; set; }
  
  
          //parameters from left side panel, for search
          [BindProperty]
          public SearchParametersModel paramsearch { get; set; }
  
  
          public void OnGet()
          {
              //bind search dropdowns
              this.accessgrouplist = new SelectList(PopulateAcessGroups(), &quot;AccessRuleGroupCode&quot;, &quot;AccessRuleGroup&quot;);
              this.accesscategorylist = new SelectList(PopulateAcessCategories(), &quot;AccessRuleCategoryCode&quot;, &quot;AccessRuleCategory&quot;);
          }
  
          public IActionResult OnPost() 
          {
              //check validators
              if (ModelState.IsValid == false) 
              {
                  return Page();
              }
  
              //get SEARCH parameters as test
              var ww = paramsearch.BeginDate;
              var www = paramsearch.AccessRuleGroupCode;
              var ww1w = paramsearch.AccessRuleCategoryCode;
              var ww2w = paramsearch.SortOrder;
  
  
              return RedirectToPage(&quot;/Index&quot;);
          }
  
          //hard coded dropdown data, will be replaced by database stuff
          private static List&lt;AccessRuleGroupModel&gt; PopulateAcessGroups()
          {
              List&lt;AccessRuleGroupModel&gt; groups = new List&lt;AccessRuleGroupModel&gt;();
              groups.Add(new AccessRuleGroupModel { AccessRuleGroupCode = 1, AccessRuleGroup = &quot;Group 1&quot; });
              groups.Add(new AccessRuleGroupModel { AccessRuleGroupCode = 2, AccessRuleGroup = &quot;Group 2&quot; });
              groups.Add(new AccessRuleGroupModel { AccessRuleGroupCode = 3, AccessRuleGroup = &quot;Group 3&quot; });
              return groups;
          }
  </code></pre>
  <p>And a couple of the class definitions:</p>
  <pre class="lang-cs prettyprint-override"><code>        public class AccessRuleGroupModel
      {
          [Key]
          public int AccessRuleGroupCode { get; set; }
          public string AccessRuleGroup { get; set; }
      }
      public class SearchParametersModel
      {
          public DateTime BeginDate { get; set; }
          public DateTime EndDate { get; set; }
          public string AccessRuleCategoryCode { get; set; }
          public string AccessRuleGroupCode { get; set; }
          public string SortOrder { get; set; }
      }
  </code></pre>
  <p>Really hoping someone can point out what I'm missing.</p>
  <p>Thanks in advance ,
  Jim W</p>