我可以在asp.net mvc中使用两个webgrids吗?

时间:2015-04-27 19:31:42

标签: c# .net asp.net-mvc webgrid

我点了这个链接http://www.codeproject.com/Tips/615776/WebGrid-in-ASP-NET-MVC 这适用于单个webgrid,但如果我在同一页面中创建两个具有不同列数的webgrids,我将收到错误如何解决此问题

@{
    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>

0 个答案:

没有答案