asp.net-mvc-3 - 访问 WebGrid 中的模型数据

标签 asp.net-mvc-3 entity-framework-4 webgrid

如何访问 WebGrid 中的其他子模型信息?

var personGrid = new WebGrid(source: Model.People,
        ajaxUpdateContainerId: "personGrid",
        ajaxUpdateCallback: "jQueryTableStyling",
        defaultSort: "PersonID");

@personGrid.GetHtml(
        tableStyle: "webgrid",
        headerStyle: "webgrid-header",
        footerStyle: "webgrid-footer",
        alternatingRowStyle: "zebra",
              columns: personGrid.Columns(
                   personGrid.Column("PersonID", "Person ID"),
                   personGrid.Column("Name", "Name"),
                   // This line isn't working and I'm not sure how to get it to work.
                   personGrid.Column(model => model.Career.Title) 
               )
        )

最佳答案

尝试:

personGrid.Column(format: @<text>@item.Career.Title</text>) 

关于asp.net-mvc-3 - 访问 WebGrid 中的模型数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5476267/

相关文章:

c# - 网页上的嵌套 foreach 循环

asp.net-mvc - 如何将 "/img/"路由到 ASP.NET MVC 3 中的 "/Content/img"文件夹?

.net - 如何查看实体集和未提交的更改?

entity-framework-4 - Entity Framework Code First 延迟加载非导航属性

css - 在 mvc 中设置 webgrid 的标题样式

javascript - HTML、WebMatrix、Razor 等新手处理 WebGrid

asp.net-mvc - 自定义授权属性(后续)

c# - Jquery/ajax 从类中获取对象并在我 View 中的文本框中使用它

entity-framework - 如何使用 Entity Framework 4 和存储库模式实现通用 GetById 方法?

c# - MVC WebGrid 是开源的吗?