2011-03-29 4 views
2

Comment puis-je accéder à des informations de sous-modèle supplémentaires dans un WebGrid?Accès aux données du modèle dans 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) 
       ) 
     ) 

Répondre

3

Essayez:

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