Blog Archives

The WebGrid In MVC

Something that new comers to MVC may wonder about, is how to create something like a GridView in MVC.  I know this was something I ran into, but quickly found the answer.  Meet the WebGrid.  The WebGrid is just that, it will create a grid of your tabular data to display nice and neatly on your view.

To make use of a WebGrid you have to perform two basic steps; new up a WebGrid object, and invoke that object’s GetHtml method.

When we new up a WebGrid we can provide some basic details for it.  Things like the source of the data, the columns you will display. how many rows per page, if it allows paging and if it allows sorting.  Lets provide an example,this example uses a model that contains: EmployeeName, SupervisorName, and Submitted.

Read the rest of this entry