title: How to bind an Html.DropDownList without ViewData (Strongly-Typed View)
body: <p>I can't seem to find a good blog post that shows how to bind a model to a view without the magic strings "ViewData" (using a strongly-typed view is the approach I'm trying to take)</p>
  
  <p>Does anyone know what I need to alter in the below to bind this directly to my model?</p>
  
  <p><strong>View</strong></p>
  
  <pre><code>&lt;%@ Page Language="VB" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage(Of IEnumerable (Of MvcApplication1.Category))" %&gt;
  &lt;asp:Content ID="aboutContent" ContentPlaceHolderID="MainContent" runat="server"&gt;
      &lt;%=Html.DropDownList("CategoryList")%&gt;
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>Function Index() As ActionResult
      Dim list As New List(Of Category)
      list.Add(New Category With {.CategoryID = 1, .CategoryName = "Test1"})
      list.Add(New Category With {.CategoryID = 2, .CategoryName = "Test2"})
  
      Return View()
  End Function
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>The final solution in VB is shown below, thanks for the big response!</p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>Function Index() As ActionResult
      Dim id As Integer = 1
      Dim ProductObject As Product = mProductService.GetProductById(id)
  
      Return View(ProductObject)
  End Function
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>&lt;%=Html.DropDownList("Category", New SelectList(Model.Categories, "CategoryID", "CategoryName"))%&gt;
  </code></pre>
  
  <p><strong>Product Class (w/ a IEnumeralbe property for the categories)</strong></p>
  
  <pre><code>Public Class Product
      Public Sub New()
  
      End Sub
  
  
      Private mProductID As Integer
      Public Property ProductID() As Integer
          Get
              Return mProductID
          End Get
          Set(ByVal value As Integer)
              mProductID = value
          End Set
      End Property
  
      ReadOnly Property Categories() As IEnumerable(Of Category)
          Get
              Dim list As New List(Of Category)
              list.Add(New Category With {.CategoryID = 1, .CategoryName = "Test1"})
              list.Add(New Category With {.CategoryID = 2, .CategoryName = "Test2"})
  
              Return list
          End Get
      End Property
  
  End Class
  </code></pre>