我想在同一页面中显示两个填充了相同模型的webgrids,但是一个网格没有显示太多数据,而另一个网格显示完整数据。执行以下代码后,我得到Column "Quantity" does not exist
之类的异常,如果我排序第二个网格的数量列,如何解决这个问题。这是我的代码
@{
var grid = new WebGrid(Model, canPage: true, rowsPerPage: 5,
selectionFieldName: "selectedRow",ajaxUpdateContainerId: "gridContent");
grid.Pager(WebGridPagerModes.NextPrevious);}
<div id="gridContent">
@grid.GetHtml(tableStyle: "webGrid",
headerStyle: "header",
alternatingRowStyle: "alt",
selectedRowStyle: "select",
columns: grid.Columns(
grid.Column("Id", format: (item) => item.GetSelectLink(item.Id)),
grid.Column("Name", format: (item) => item.GetSelectLink(item.Name)),
grid.Column("Description", "Description", style: "description")
))
</div>
@{
var gridsecond = new WebGrid(Model, canPage: true, rowsPerPage: 5,
selectionFieldName: "selectedRow", ajaxUpdateContainerId: "secondgridContent");
grid.Pager(WebGridPagerModes.NextPrevious);}
<div id="secondgridContent">
@gridsecond.GetHtml(tableStyle: "webGrid",
headerStyle: "header",
alternatingRowStyle: "alt",
selectedRowStyle: "select",
columns: gridsecond.Columns(
gridsecond.Column("Id", format: (item) => item.GetSelectLink(item.Id)),
gridsecond.Column("Name", format: (item) => item.GetSelectLink(item.Name)),
gridsecond.Column("Description", "Description", style: "description"),
gridsecond.Column("Quantity", "Quantity")
))
</div>
我正在关注下面显示的链接 http://www.codeproject.com/Tips/615776/WebGrid-in-ASP-NET-MVC