model:
public class 培训中心
{
[Key]
public Guid 中心标识 { get; set; }
public string 中心名称 { get; set; }
public virtual List<科室> 科室s { get; set; }
}
public class 科室
{
[Key]
public Guid 科室标识 { get; set; }
public Guid 中心标识 { get; set; }
public string 科室名称 { get; set; }
}
生成中心list
public List<SelectListItem> GetEduCenters()
{
ChildEduDbContext db = new ChildEduDbContext(); var quert = db.Centers;
List<SelectListItem> item = new List<SelectListItem>();
foreach (var it in quert)
{
item.Add(new SelectListItem { Text = it.中心名称, Value = it.中心标识.ToString() }); }
return item;
}绑定
@Html.DropDownListFor(model => model.中心标识.ToString(), ViewData["中心"] as SelectListItem)错误提示
Compiler Error Message: CS1928: 'System.Web.Mvc.HtmlHelper<ChildEdu.Models.科室>' does not contain a definition for 'DropDownListFor' and the best extension method overload 'System.Web.Mvc.Html.SelectExtensions.DropDownListFor<TModel,TProperty>(System.Web.Mvc.HtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel,TProperty>>, System.Collections.Generic.IEnumerable<System.Web.Mvc.SelectListItem>)' has some invalid arguments
public class 培训中心
{
[Key]
public Guid 中心标识 { get; set; }
public string 中心名称 { get; set; }
public virtual List<科室> 科室s { get; set; }
}
public class 科室
{
[Key]
public Guid 科室标识 { get; set; }
public Guid 中心标识 { get; set; }
public string 科室名称 { get; set; }
}
生成中心list
public List<SelectListItem> GetEduCenters()
{
ChildEduDbContext db = new ChildEduDbContext(); var quert = db.Centers;
List<SelectListItem> item = new List<SelectListItem>();
foreach (var it in quert)
{
item.Add(new SelectListItem { Text = it.中心名称, Value = it.中心标识.ToString() }); }
return item;
}绑定
@Html.DropDownListFor(model => model.中心标识.ToString(), ViewData["中心"] as SelectListItem)错误提示
Compiler Error Message: CS1928: 'System.Web.Mvc.HtmlHelper<ChildEdu.Models.科室>' does not contain a definition for 'DropDownListFor' and the best extension method overload 'System.Web.Mvc.Html.SelectExtensions.DropDownListFor<TModel,TProperty>(System.Web.Mvc.HtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel,TProperty>>, System.Collections.Generic.IEnumerable<System.Web.Mvc.SelectListItem>)' has some invalid arguments
解决方案 »
- YxShop_V4.51 有人用这个开源的电子商务吗???
- 救急-----------Request.Cookies.Expires 设置有效期两天怎么做的
- LinkButton传值问题
- charset设置为gb2312的问题
- 框架页向多页面传值
- 急!马上给分!动态生成的DIV为什么会被其他控件盖住?怎么样可以使DIV始终显示在最上层?
- 关于global.asax的问题,高人们请进来指点一下谢谢了!
- 我用dom创建新节点时多了xmlns=""是怎么回事呢?
- ★★★★★同样的代码,为什么在ASPX能执行,在ASCX就不能执行呢?
- 怎么把Hyperlink对象中字体的下划线去掉?
- 【新手求助】关于错误页配置,访问html页不起作用
- 启动项目后,无法自动打开ie,并且vs2008无响应
public static class Utility
{
public static List<SelectListItem> GetEduCenters()
}//@Html.DropDownListFor(model => model.中心标识,Utility.GetEduCenters() )不明白为什么新手那么喜欢tostring,虽然我当年也很喜欢tostring