【问题标题】:In mvc4 i am using grid view but it is showing error在 mvc4 我使用网格视图,但它显示错误
【发布时间】:2016-08-01 22:27:01
【问题描述】:
@model IEnumerable<gridview.Models.emp>
@{
var grid = new WebGrid(Model, canPage: true, rowsPerPage: 5,
selectionFieldName: "selectedRow", ajaxUpdateContainerId: "gridContent");
grid.Pager(WebGridPagerModes.All);
}

但这里显示错误

错误 1 ​​找不到类型或命名空间名称“WebGrid”(您是否缺少 using 指令或程序集引用?)
c:\Users\anand.kumar\Documents\Visual Studio 2013\Projects\gridview\gridview\Views\Home\Index.cshtml 3 20 网格视图

【问题讨论】:

  • 然后添加程序集 (System.Web.Helpers)

标签: asp.net asp.net-mvc-4


【解决方案1】:

将引用 System.Web.Helpers 添加到您的项目并重建项目。

试试这个:

        <assemblies>
            <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        </assemblies>

必须添加到网络配置中,在system.web 部分下,带有compilation 标签,所以它看起来像:

<system.web>
    <compilation debug="true" targetFramework="4.0">
        <assemblies>
            <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        </assemblies>
    </compilation>
</system.web>

1) 在Visual Studio 中打开NuGet Package Manager 并搜索“microsoft-web-helper” 并安装。

2) 安装后在您的解决方案中打开web.config 并将connectionStringName 参数更改为DefaultMembershipProviderDefaultRoleProviderDefaultSessionProvider(如果不这样做,您可能会遇到'DefaultConnection' is not found in the应用程序配置或连接字符串为空。”错误。

3) 重建您的项目,然后在您的 razor 视图中使用如下类似的定义。

1) 只需添加对System.Web.Helpers 2.0.0.0 dll 的引用,Basic 模板默认不包含该引用。

2) 添加引用后,需要打开dll的属性,将Copy Local改为True

【讨论】:

  • 编辑了答案@AnandA
  • 删除 dll 引用并重试这些步骤。
  • @using GridMvc.Html 我也在视图中添加了但同样的错误
  • 先生,我正在使用 mvc4
  • 我删除了所有 dll 引用 bot 无法正常工作,你可以发送任何其他示例,以便我可以关联事情
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-11-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多