Mona Coder Mona Coder - 7 months ago 31
C# Question

Issue on Populating Data on Drop-down List in ASP.Net MVC

I am trying to Load data from

table into a Bootstrap Drop down list like:

<div class="form-group">
<label for="sel1"></label>
<select class="form-control" id="cat">
<option>Select From The List</option>
DataEntities ctx = new DataEntities();
var cat = ctx.Categories.OrderByDescending(p => p.CategoryName);
foreach (var item in cat)

but I am getting this is result

enter image description here

the count of
is equal to number of rows in
table but I am not getting the actual value! . Can you please let me know what i am doing wrong?


You're missing an @ symbol in your option tag.

foreach (var item in cat)

In your code, you're just adding the string "item" for each item in cat.