.net MVC 泛型类 绑定到 html.dropdownlist 注意是mvc的dropdownlist,也就是将泛型转换成selectlist类型,请问怎么转。谢谢了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public ActionResult Create() { ViewBag.GenreId = new SelectList(db.Genres, "GenreId", "Name"); ViewBag.ArtistId = new SelectList(db.Artists, "ArtistId", "Name"); return View(); } @Html.DropDownList("GenreId", "Please Select") @Html.ValidationMessageFor(model => model.GenreId) db.Genres?是什么?是不是Linq查询啊,linq查询出来的好像也是list<T>吧,但是我把List<T>类型的返回值放在那里不行, public ActionResult Index() { Models.Ma_Vocation_Repository mo=new Models.Ma_Vocation_Repository (); List<Models.Ma_Vocation> ma = new List<Models.Ma_Vocation>(); ma=mo.SelectAll(); var selist = new SelectList(ma,"Id","Name"); ViewData["mv"] = selist; return View(); }提示:不存在具有键“mv”的“IEnumerable<SelectListItem>”类型的 ViewData 项。小弟初学,见笑…… 唉~我没用Linq ,自己写的泛型类,郁闷啦,还有人不,给个解决啊,救命啊 VS2008,C# form程序调试的时候不报错,怎么设置呢? 怎么用C#读取电脑硬盘的使用时间 关于IPC连接问题 C#字符串随机排列 如何自动生成文档?? c#和C++的区别 关于Access2003的问题 关于DataGridView在WinForm的基础应用问题,请大家帮帮我吧! !!!!!列值比较的问题,快来帮帮我呀!!!! 有什么办法可以保护自己做的项目不被修改? C++结构类型 转化为C#对应的类型问题 求教大神如何使用多点触控来控制程序?
{
ViewBag.GenreId = new SelectList(db.Genres, "GenreId", "Name");
ViewBag.ArtistId = new SelectList(db.Artists, "ArtistId", "Name");
return View();
} @Html.DropDownList("GenreId", "Please Select")
@Html.ValidationMessageFor(model => model.GenreId)
{
Models.Ma_Vocation_Repository mo=new Models.Ma_Vocation_Repository ();
List<Models.Ma_Vocation> ma = new List<Models.Ma_Vocation>();
ma=mo.SelectAll();
var selist = new SelectList(ma,"Id","Name");
ViewData["mv"] = selist;
return View();
}
提示:不存在具有键“mv”的“IEnumerable<SelectListItem>”类型的 ViewData 项。
小弟初学,见笑……