title: Pass List data along with ViewModel to view and populate list data in drop down
body: <p>I have ModelView which I have created for purpose to create new record instance via view-- razor form. In controller I need to assign list data to ViewModel; IEnumerable and then pass this model along with with list data (of CategoryType) which then in view I need to populate in drop-down list, followed by ID of selected CategoryType send back to controller along with other data.</p>
  
  <p>I have assign IEnumerable value to model in controller but not sure is correct and how to do rest part in view ???</p>
  
  <h2>View Model - CompanyProfileModelView</h2>
  
  <pre><code>public class CompanyProfileModelView
  {
      public Company _Company { get; set; }
  
      public IEnumerable&lt;CategoryType&gt; _CategoryType { get; set; } 
  }
  </code></pre>
  
  <h2>Model Class</h2>
  
  <pre><code>public class CategoryType
  {
      public int CategoryTypeID { get; set; }
      public string CategoryTitle { get; set; }
  
      public ICollection&lt;Company&gt; Companies { get; set; }
  }
  </code></pre>
  
  <h2>Controller Class</h2>
  
  <pre><code> [HttpGet]
      public ActionResult CreateCompany()
      {
          var _listData = _appFunctions.GetAllCategory();
  
          var _model = new CompanyProfileModelView
          {
              _CategoryType = _listData
              ??????????????
          };
  
          return PartialView("_CreateNewCompanyPartial", _model);
      }
  
      [HttpPost]
      public ActionResult CreateCompany(CompanyProfileModelView _model)
      {
          try
          {
              if (ModelState.IsValid)
              {
                  //my code will be here to read for input data
              }
          }
          catch (DataException ex)
          {
              ModelState.AddModelError("", "Unable To Create New Function Navigation" + ex);
          }
  
          return RedirectToAction("Home");
      }
  </code></pre>
  
  <h2>View</h2>
  
  <pre><code>@model App.DAL.Model.CompanyProfileModelView
  
   @using (Html.BeginForm("CreateCompany", "CompanyProfile", FormMethod.Post, new { id = "NewFunctionNavigationForm" }))
  {
   &lt;div class="form-group"&gt;
          @Html.LabelFor(@model =&gt; @model._Company.CompanyName, new { @class = "control-label col-md-2" })
          &lt;div class="form-group"&gt;
              @Html.EditorFor(@model =&gt;@model._Company.CompanyName)
              @Html.ValidationMessageFor(@model=&gt;@model._Company.CompanyName)
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="form-group"&gt;          
          // need help here for dropdown of CategoryType list  
      &lt;/div&gt;
  
      &lt;div class="form-group"&gt;
         &lt;div class="col-md-offset-2 col-md-10"&gt;
            &lt;input type="submit" value="Create" class="btn btn-default" /&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  }
  </code></pre>