webgrid reference is not found in view

15,845

Solution 1

  1. Just add reference to System.Web.Helpers 2.0.0.0 dll which Basic template does not include by default.
  2. After adding the reference, you need to open property for the dll and change Copy Local to True.
  3. Rebuild your project

Solution 2

I was able to solve this by updating the reference to the helper dll and setting the copy local to true to overwrite the old version. I somehow had a bad version get referenced, possibly through an old nuget package.

Share:
15,845
gleasonomicon
Author by

gleasonomicon

Updated on June 26, 2022

Comments

  • gleasonomicon
    gleasonomicon about 2 years

    I'm trying to do a basic implementation of the asp.net mvc webgrid mentioned in this tutorial: http://msdn.microsoft.com/en-us/magazine/hh288075.aspx

    I'm using asp.net mvc 4.

    Upon doing a simple reference to the grid (the first part of the tutorial), I'm getting this error in the view:

    Compiler Error Message: CS0246: The type or namespace name 'WebGrid' could not be found (are you missing a using directive or an assembly reference?)

    The code for the cshtml file is below:

    @model IEnumerable<Company.Core.DataAccess.Models.TransactionLog>
    @{
        ViewBag.Title = "Index";
    }
    
    @{ 
     var grid = new WebGrid(Model, defaultSort:"TransactionLogId"); 
    } 
    @grid.GetHtml()
    
    @section Scripts {
        @Scripts.Render("~/bundles/jqueryval")  
    }
    

    I have a reference to System.Web.Helpers. If I put an @using directive for it in the view, the same message remains. Can anyone help out?