本文介绍了获取一个方法.ToList()在MVC WebGrid中工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我在我的busniess逻辑中有一个方法,我正在为默认值分配和创建一个List:
var ppc1Result = POCMethods.GetPPCRatesAndStatusesInRowsOverallMedSurg(PPCRatesAndStatusesInRowsOverallMedSurgDTO.Default()) .ToList();
当我调试我想要的数据时,变量'ppc1Result'中有,但我该如何使用它WebGrid中的列表。当我从列表中写出列名时,我收到一条错误,说列名不存在,这是我的WebGrid:
@ {
var grid = new WebGrid(ppc1Result,canPage:true,rowsPerPage:5,
selectionFieldName:selectedRow,ajaxUpdateContainerId:measuresMain);
grid.Pager(WebGridPagerModes.NextPrevious);
}
< div id =measuresMain>
@ grid.GetHtml(
tableStyle:webGrid,
headerStyle:header,
alternatingRowStyle:alt,
selectedRowStyle:select,
列:grid.Columns(
grid.Column(DischargeswAtRisk,DischargesAtRisk),
grid.Column(DischargesWithPPC,DischargesWithPPC),
grid.Column (DRGType,DRGType),
grid.Column(NormativeRate,NormativeRate),
grid.Column(OverallDischargeCounts,OverallDischargeCounts),
grid。列(SumWeight,SumWeight),
grid.Column(TotalImpact,TotalImpact)
))
< / div>
导致错误。
解决方案
So I have a method in my busniess logic that I am assigning defaults to and creating a List:
var ppc1Result = POCMethods.GetPPCRatesAndStatusesInRowsOverallMedSurg(PPCRatesAndStatusesInRowsOverallMedSurgDTO.Default()).ToList();
When I debug the data I want is there in the variable 'ppc1Result', but how do I use this list in a WebGrid. When I write out the column names from the list, I am getting an error saying the column name doesn't exist, here's my WebGrid:
@{ var grid = new WebGrid(ppc1Result, canPage: true, rowsPerPage: 5, selectionFieldName: "selectedRow", ajaxUpdateContainerId: "measuresMain"); grid.Pager(WebGridPagerModes.NextPrevious); } <div id="measuresMain"> @grid.GetHtml( tableStyle: "webGrid", headerStyle: "header", alternatingRowStyle: "alt", selectedRowStyle: "select", columns: grid.Columns( grid.Column("DischargeswAtRisk", "DischargesAtRisk"), grid.Column("DischargesWithPPC", "DischargesWithPPC"), grid.Column("DRGType", "DRGType"), grid.Column("NormativeRate", "NormativeRate"), grid.Column("OverallDischargeCounts", "OverallDischargeCounts"), grid.Column("SumWeight", "SumWeight"), grid.Column("TotalImpact", "TotalImpact") )) </div>
This results in an error.
解决方案
这篇关于获取一个方法.ToList()在MVC WebGrid中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!