0
我已經使用實體框架從數據庫生成了下拉列表。我可以看到我的下拉列表,但我得到重複的值。我如何刪除重複值?從下拉列表數據庫中刪除重複項目
controller:
DBEntities db = new DBEntities();
var a = db.AspNetUsers.Select(h => new SelectListItem
{
Value = h.Nationality,
Text = h.Nationality
}).ToList();
ViewData["nationselection"] = new SelectList(a, "Value", "Text");
View:
@Html.DropDownList("selectedItem", (SelectList)ViewData["nationselection"], "-Selce-", new
{
onchange = @"
var form = document.forms[0];
form.action='GetEmployeeDetails';
form.submit();"
})