相关疑难解决方法(0)

如何在cshtml视图中使用WebGrid?

我可以在任何控制器中使用WebGrid,例如:

var grid = new WebGrid(emailsFetched, columnNames);

我必须在我的ASP.NET MVC项目中添加一个引用System.Web.Helpers.

但是当我尝试直接在视图中使用这个网格时(为了避免控制器中的实例化和其他设置),它说:The type or namespace 'WebGrid' cannot be found.好的,我也尝试在这里添加一个引用:

@using System.Web.Helpers 但这引发了另一个问题:

There is no build provider registered for the extension '.cshtml'. You can register one in the <compilation><buildProviders> section in the machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.

这很奇怪......我在网上看到了足够的例子,它们正在使用WebGrid并且不必在cshtml视图中声明任何内容......

你能告诉我怎么解决这个问题吗?或者为什么我遇到这个非常丑陋的问题?

asp.net-mvc webgrid razor

10
推荐指数
2
解决办法
3万
查看次数

标签 统计

asp.net-mvc ×1

razor ×1

webgrid ×1