title: How can I add Selected attribute with the the drop down list item
body: <p>I have the following Record, and from the record I am trying to create the cascade dropdown. It is working fine but how can I add the selected attribute if the data item has selected = true. I have the following record. How can I add conditionally selected attribute
  if item.IsSelected , Selected = IsSelected.</p>
  <pre><code>public IEnumerable&lt;Category&gt; GetCategories()
      {
          return new List&lt;Category&gt;
          {
              new Category { CategoryId = 1, CategoryName=&quot;Category 1&quot; },
              new Category { CategoryId = 2, CategoryName=&quot;Category 2&quot; },
              new Category { CategoryId = 3, CategoryName=&quot;Category 3&quot; }
          };
      }
      public IEnumerable&lt;SubCategory&gt; GetSubCategories(int categoryId)
      {
          var subCategories = new List&lt;SubCategory&gt; {
              new SubCategory { SubCategoryId = 1, CategoryId = 1, SubCategoryName=&quot;SubCategory 1&quot;, IsSelected=false},
              new SubCategory { SubCategoryId = 2, CategoryId = 2, SubCategoryName=&quot;SubCategory 2&quot; IsSelected= false },
              new SubCategory { SubCategoryId = 3, CategoryId = 3, SubCategoryName=&quot;SubCategory 3&quot; IsSelected= true},
              new SubCategory { SubCategoryId = 4, CategoryId = 1, SubCategoryName=&quot;SubCategory 4&quot; IsSelected= false},
               
          };
          return subCategories.Where(s =&gt; s.CategoryId == categoryId);
      }
  </code></pre>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>@section scripts{ 
  &lt;script&gt;
      $(function () {
          $("#CategoryId").on("change", function() {
              var categoryId = $(this).val();
              $("#SubCategoryId").empty();
              $("#SubCategoryId").append("&lt;option value=''&gt;Select SubCategory&lt;/option&gt;");
              $.getJSON(`?handler=SubCategories&amp;categoryId=${categoryId}`, (data) =&gt; {
                  $.each(data, function (i, item) {
                      $("#SubCategoryId").append(`&lt;option value="${item.subCategoryId}"&gt;${item.subCategoryName}&lt;/option&gt;`);
                  });
              });
          });
      });
  &lt;/script&gt;
  }</code></pre>
  </div>
  </div>
  </p>