2011-03-29 66 views
2

如何訪問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) 
       ) 
     ) 

回答

3

嘗試:

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