title: Drop Down list values from SQL Query in ASP.NET
body: <p>I need to have values from a SQL query be in a dropdown list on my webpage. I created the connection in the web.config file and have been able to render values from the query on my page, but can't figure out my dropdown list problem. I'm working in Visual Studio 2012 and the page is in CSHTML.</p>
  
  <p>Here is the code that I have so far... and it brings in the values from the query, but it displays each value in it's own row of the table instead of just having them as values in the dropdown list of the single row.</p>
  
  <pre><code>@{var db = Database.Open("CARD");
      var Vendors = db.Query("SELECT VendorName FROM tbl_Vendors");}
          &lt;p style="text-align: center; font-family: verdana; font-size: 20px"&gt;Vendor&lt;/p&gt;
          &lt;table border="1"&gt;
              &lt;tr bgcolor="beige"&gt;
                  &lt;th&gt;Vendor&lt;/th&gt;
              &lt;/tr&gt;
             @foreach (var row in Vendors)
             {
              &lt;tr bgcolor="#E0E0E0"&gt;
                  &lt;td&gt;
  
                    &lt;select id="dropdown" class="select-box" name="Vendor"&gt;
                                  &lt;option&gt;@row.VendorName&lt;/option&gt;
                          &lt;/select&gt;
                  &lt;/td&gt;
              }
  </code></pre>
  
  <p>Thanks in advance for your help!</p>
  
  <p>James</p>