ASP.NET Core 2.0中的WebGrid

问题描述 投票:0回答:1
@using System.Web.Helpers

 @{
        WebGrid grid = new WebGrid(Model, canPage: true, rowsPerPage: 5);
    }

        @grid.GetHtml(tableStyle: "WebGrid",
          headerStyle: "header",
          alternatingRowStyle: "alt",
          selectedRowStyle: "select",
          columns: grid.Columns(
          grid.Column("UploadBy", "UploadBy"),
          grid.Column("UploadPath", "UploadPath")
         ))

上面的代码在@ grid.GetHtml中给出了错误,比如“引用类型'IHtmlString'声称它是在System.Web中定义的,但是找不到它”

我试图添加一个引用DLL,但它不被接受。应该做什么。

asp.net core webgrid
1个回答
2
投票

你可以尝试使用另一个组件,我推荐MVC6网格http://mvc6-grid.azurewebsites.net/

基本上它使用几乎相同的语法,因此对您当前的代码进行微小的更改,请查看下面的示例代码

@model IEnumerable<PersonModel>

@(Html
.Grid(Model)
.Build(columns =>
{
columns.Add(model => model.Name).Titled("Name");
columns.Add(model => model.Surname).Titled("Surname");

columns.Add(model => model.Age).Titled("Age");
columns.Add(model => model.Birthday).Titled("Birth date");
columns.Add(model => model.IsWorking).Titled("Employed");
})
.Filterable()
.Sortable()
.Pageable()
)

它还有许多其他功能,可以使.net核心更容易

© www.soinside.com 2019 - 2024. All rights reserved.