Questions tagged [webgrid]

WebGrid is a view control built in to the ASP.NET Web Pages Framework. It displays a sortable, pageable HTML grid given a collection, and is customizable in various ways, making use of .NET 4.0's "dynamic" object type.

The ASP.NET Web Pages WebGrid provides a kind of quick-scaffolded functionality for displaying tabular information in ASP.NET Web Pages, or ASP.NET MVC when using the Web Pages (Razor) view engine. Given an IEnumerable data source, it is possible to construct a functional HTML data table, with sorting and paging, with a single line of code in the View (Razor syntax, for example):

@( new WebGrid(data).GetHtml() )

The control offers customization of various styling, sorting, and paging functionality; as well as the ability to define the column contents either as raw data, or as templated HTML.

822 questions
28
votes
6 answers

To WebGrid or not to WebGrid...what is the answer?

I'm reading and hearing some pain points and am wondering if I should even go that route. Not to mention, I cannot seem to find any definitive documentation (from Microsoft). If you say I shouldn't use it, what route would you suggest? I'm trying…
jsteve81
  • 735
  • 2
  • 6
  • 16
28
votes
2 answers

Razor webgrid ajax paging and sorting

I'm trying to learn how to use Razor WebGrid in MVC3. How does the ajaxUpdateCallback parameter work?
Sean Cain
  • 898
  • 2
  • 10
  • 16
19
votes
8 answers

Using data in a HTML.ActionLink inside a WebGrid.column, not possible?

I have the following WebGrid in my ASP.NET MVC3 test application. It displays a list of customers: @grid.GetHtml( tableStyle: "grid", headerStyle: "head", alternatingRowStyle: "alt", columns: grid.Columns ( grid.Column(format:…
Thomas
  • 193
  • 1
  • 1
  • 4
17
votes
4 answers

How to format date in mvc web grid

I have a web grid and I am not using razor syntex.Rather I am using the .aspx form. the code is below; <% var grid = new WebGrid(Model,defaultSort:"PublishDate",rowsPerPage:10); %> <%: grid.GetHtml( …
Reza.Hoque
  • 2,690
  • 10
  • 49
  • 78
17
votes
1 answer

How to disable Paging in WebGrid

I've searched the documentation (http://msdn.microsoft.com/en-us/library/system.web.helpers.webgrid.webgrid(v=vs.111).aspx), and found "canPage: false" - which does not work. Saying there is no parameter named 'canPage'. Other sites have said…
Protected Identity
  • 241
  • 1
  • 2
  • 11
14
votes
2 answers

How can I use DisplayName data annotations for column headers in WebGrid?

I have a Car class that I'm trying to display in an MVC 3 view using the WebGrid helper. Below are the Car and it's metadata class. Car class: [MetadataType(typeof(CarMetadata))] public partial class Car { // car implementation } Car…
80bower
  • 1,151
  • 1
  • 14
  • 22
14
votes
3 answers

ASP.NET MVC 3 WebGrid paging issue

My data access layer returns collection with rows for single page and total number of rows. Unfortunately WebGrid component does not allow to specify total number of rows or total number of pages (these properties are read-only). Has anyone had to…
Daniil Harik
  • 4,619
  • 10
  • 55
  • 60
14
votes
3 answers

Filter is getting lost in WebGrid + Paging + Sorting + Filtering in .NET 4.0

I've implemented a WebGrid. Sorting, paging and filtering do not work together. They work when you use them alone. When you combine the three, at the same time, filtering doesn't work. The symptom: Filter the resultset, then sort. or Filter the…
101010
  • 14,866
  • 30
  • 95
  • 172
13
votes
3 answers

MVC 3 Webgrid - how do you hide columns you do not want to be visible?

I have a webgrid and there is a column I want to be visible only to certain users. Currently I have coded the grid as follows if (Context.User.IsInRole(Role.Inputter) || Context.User.IsInRole(Role.Administrator)) { @grid.GetHtml(columns:…
arame3333
  • 9,887
  • 26
  • 122
  • 205
13
votes
4 answers

asp.net mvc 3 webgrid sorting remains ?sortdir=ASC

I'm experimenting a bit with several grids in asp.net mvc. Microsoft has a grid too know in the prerelease of mvc 3 so I thought I'll try that one out. The basic functionality is quite easy to implement but when it comes to sorting, I'm having some…
denappel
  • 509
  • 3
  • 6
  • 13
12
votes
1 answer

WebGrid Column Format Issue in MVC3

I've been trying to change the format of a single column in a WebGrid without much success. Said column is this: grid.Column( columnName: "EmailAddress", header: "Email Address", format:(item) => Html.EmailLink(item.EmailAddress,…
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
12
votes
3 answers

ASP.NET MVC3 WebGrid format: parameter

I am trying to use the new WebGrid in ASP.NET MVC3 and one of the columns I want to display set of link icons that performs various actions (Edit, View, Delete)... For this purpose I have a HtmlHelper extensions that basically outputs following…
zam6ak
  • 7,229
  • 11
  • 46
  • 84
12
votes
3 answers

MVC3 WebGrid Formatting or Styling Column Headers

I'm using the new MVC3 WebGrid. So far so good, just having issues styling/formatting the column headers. The best I've got is a workaround that applies the same css class from the first row of the WebGrid to the table header. var headerCells =…
sambomartin
  • 6,663
  • 7
  • 40
  • 64
11
votes
10 answers

How to make a MVC 3 Webgrid with checkbox column?

The code below will insert an actionlink into one of the web grids' columns. @{ View.Title = "Index"; Layout = "~/Views/Shared/_Layout.cshtml"; var usersGrid = new WebGrid(source: Model, rowsPerPage:…
4imble
  • 13,979
  • 15
  • 70
  • 125
10
votes
1 answer

Conditionally display an image in webgrid - mvc 3

In my webgrid I need to display images based on the value .. Code is given below @model TraktorumMVC.Models.ManagePhotos @{ ViewBag.Title = "ManagePhotos"; Layout = "~/Views/Shared/_Layout.cshtml"; var grid = new…
Null Pointer
  • 9,089
  • 26
  • 73
  • 118
1
2 3
54 55