title: How can I push ItemName to my database(SQL) from Select2() dropdown list
body: <p>i am new on asp.net razor page</p>
  <p>this is my Html</p>
  <pre class="lang-html prettyprint-override"><code>&lt;div class=&quot;form-group row&quot;&gt;
                  &lt;div class=&quot;col-4&quot;&gt;
                      &lt;select class=&quot;form-control&quot; id=&quot;itemslist&quot; name=&quot;itemName&quot; asp-items=&quot;Model.Itemslist&quot;&gt;
                          &lt;option value=&quot;SSS&quot;&gt;&lt;/option&gt;
                      &lt;/select&gt;
                      &lt;input class=&quot;form-control&quot; type=&quot;hidden&quot; name=&quot;itemName&quot;asp-for=&quot;Expiree.ItemName&quot;  /&gt;
                      &lt;br /&gt;
                      &lt;br /&gt;
                      @if (ViewData[&quot;Message&quot;] != null)
                      {
                          &lt;script type=&quot;text/javascript&quot;&gt;
                              window.onload = function ()
                              {
                            alert(&quot;@ViewData[&quot;Message&quot;]&quot;);
                               };
                          &lt;/script&gt;
                      }
                  &lt;/div&gt;
  </code></pre>
  <p>this my script section</p>
  <pre><code>@section scripts
  {
      &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/select2@4.0.13/dist/css/select2.min.css&quot; /&gt;
      &lt;script type=&quot;text/javascript&quot; src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js&quot;&gt;&lt;/script&gt;
      &lt;script type=&quot;text/javascript&quot; src=&quot;https://cdn.jsdelivr.net/npm/select2@4.0.13/dist/js/select2.min.js&quot;&gt;&lt;/script&gt;
      &lt;script type=&quot;text/javascript&quot;&gt;
          $(function () {
              $(&quot;#itemslist&quot;).select2();
          });
          $(&quot;body&quot;).on(&quot;change&quot;, &quot;#itemslist&quot;, function () {
              $(&quot;input[name=itemName]&quot;).val($(this).find(&quot;option:selected&quot;).text());
          });
      &lt;/script&gt;
  
  }
  </code></pre>
  <p>this my page model</p>
  <pre><code>namespace SparkAuto.Pages.Expire
  {
      public class CreateeModel : PageModel
      {
          private readonly ApplicationDbContext _db;
          public CreateeModel(ApplicationDbContext db)
          {
              _db = db;
          }
          public SelectList Itemslist { get; set; }
          [BindProperty]
          public Expiree Expiree { get; set; }
          public IActionResult OnGet()
          {
              this.Itemslist = new SelectList(_db.Items, &quot;Id&quot;, &quot;Name&quot;);
  
  
              return Page();
          }
          public async Task&lt;IActionResult&gt; OnPostAsync()
          {
             
              _db.Expiree.Add(Expiree);
              await _db.SaveChangesAsync();
  
              return RedirectToPage(&quot;Index&quot;);
          }
      }
  }
  </code></pre>
  <p>finally this my error i get Null in itemName in database</p>
  <p><a href="https://i.stack.imgur.com/UNiXT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UNiXT.png" alt="enter image description here" /></a></p>
  <p>this a screenshot from searchable select2 dropdown list i use</p>
  <p><a href="https://i.stack.imgur.com/V4WNb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V4WNb.png" alt="enter image description here" /></a></p>
  <p>I search in 3K items in this dropdown list and need to push the item name after selection</p>