摘要: @Model List<Mvc4Application.test>@{ ViewBag.Title = "Index";}<h2>Index</h2>@foreach (var item in Model){ @Html.Label(item.name)}这样会报错:“/”应用程序中的服务器错误。编译错误说明:在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。编译器错误消息:CS1973: “System.Web.Mvc.HtmlHelper<dynamic>”没有名为“Label” 阅读全文
posted @ 2013-05-03 18:14 赶路人之刚出发 阅读(570) 评论(0) 推荐(0) 编辑
摘要: MVC中ViewBag可以设置任意自定义的属性,也可以读取出来。如下面这样在controller的action方法中设置了ViewBag的一个Entires属性(该属性名字任意取)后,在相应的view中也可以读取出来,那这是怎样做到的呢? public ActionResult Index() { var mostrecentEntiries = (from m in dbContext.test orderby m.ID descending select m).Take(10); ViewB... 阅读全文
posted @ 2013-05-03 17:20 赶路人之刚出发 阅读(495) 评论(1) 推荐(0) 编辑