//动态获取数据库内容并赋值给下拉框

 

.cs代码

IEnumerable<SelectListItem> items=db.Voice.Select(c=>new SelectListItem

{

Value=SqlFunctions.StringConvert((double)c.ID),

Text=c.Name

});

ViewData["ID"]=items;

return View();

 

html:

@Html.DropDownList("ID")

相关文章:

  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
相关资源
相似解决方案