Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'd like to build a table with the helper WebGrid (MVC 4). I try to do it as shown below, but an error Failed to find name of type of namespace "WebGrid" occurres, in spite of included namespace System.Web.Heplers in the code. Also IDE underlines the word "WebGrid" as something not proper.

I understand that there is some small mistake, but I'm confused with. Please, help me.

C#
@model IEnumerable<MvcApplication_test.Models.Customer>
@using System.Web.Helpers;

@{
    Layout = null;
    ViewBag.Title = "Index";
    var grid = new WebGrid(Model, rowsPerPage: 5);
}
Posted

1 solution

have you include GetHtml method?
C#
@{
    Layout = null;
    ViewBag.Title = "Index";
    var grid = new WebGrid(Model, rowsPerPage: 5);
}
@grid.GetHtml();

please refer this article : WebGrid in ASP.NET MVC4[^]
in addition to above check below answers which may be helpfull
How to use WebGrid in a cshtml view?[^]
 
Share this answer
 
v3
Comments
brombenzol123 3-Nov-14 5:42am    
Certainly, I use the method WebGrid.GetHtml() after this part of code, but it doesn't give any results, because the compiler doesn't see the WebGrid. It looks as if I haven't imported the namespace with WebGrid at all. But as you see, I have.
DamithSL 3-Nov-14 7:21am    
brombenzol123 3-Nov-14 8:12am    
Yes! The problem was as in the article. Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900