title: How to Fill Drop Down List using Model in MVC
body: <pre><code>Function GetStateName() As List(Of SelectListItem)
      Dim ListRoomMaster As List(Of MiscMaster) = New List(Of MiscMaster)
      Dim rm As New MiscMaster
      Using conn As New SqlConnection(connectionString)
          Dim sSql = "Select * From dropdown"
  
          Dim cmd As SqlCommand = New SqlCommand(sSql, conn)
          conn.Open()
          Dim rst As SqlDataReader = cmd.ExecuteReader
          Do While rst.Read
              rm.m_ddlId = rst!id
              rm.ddlValue = rst!name
              ListRoomMaster.Add(rm)
          Loop
      End Using
      Dim Listxyz = (
          From p In Enumerable.Range(0, 20)
          Select New SelectListItem With {.Text = p.ToString(), .Value = p.ToString()})
  Return Listxyz.ToList()
  End Function
  </code></pre>
  
  <p>This is the code for GetStateName() Which I am calling from controller Before Viewing This Displays The Drop Down List With 0 to 19 numbers I know I have Miss Something But Don't Know Where to change as most of code are for Linq</p>
  
  <p>This Is Controller Code</p>
  
  <pre><code>    Function Index() As ActionResult
  
          objMisc.StateValue = objMisc.GetStateName()
          'objMisc.StateValue = obj
          Return View(objMisc)
      End Function
  </code></pre>
  
  <p>What I Exactly Want Is Fetching data from DataBase using query 
  DataBase Have field like follow
  id   | Value
  1    | xyz
  2    | abx
  3    | kvd</p>
  
  <p>I want to populate drop down List As xyz,abx,kvd
  And when abx is selected I want to store 2 in database</p>