Click here to Skip to main content
15,881,516 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

Thank you in advance for your help!

James
Posted
Updated 21-Nov-13 13:07pm
v2
Comments
bbirajdar 21-Nov-13 21:31pm    
Neither we can figure it out without looking at the code....
CodeBlack 21-Nov-13 23:27pm    
can you update your question with the code you have tried ?
jdykes1987 25-Nov-13 16:59pm    
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.

@{var db = Database.Open("CARD");
var Vendors = db.Query("SELECT VendorName FROM tbl_Vendors");}
<p style="text-align: center; font-family: verdana; font-size: 20px">Vendor</p>
<table border="1">
<tr bgcolor="beige">
<th>Vendor</th>
</tr>
@foreach (var row in Vendors)
{
<tr bgcolor="#E0E0E0">
<td>

<select id="dropdown" class="select-box" name="Vendor">
<option>@row.VendorName</option>
</select>
</td>
}

Thanks in advance for your help!

James

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900