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
4
votes
1 answer

MVC 4 Webgrid - Column Width settings using css style is not working

I am trying to set width for Webgrid column. But it is not working. Anyone help me please. Please find below my code @grid.GetHtml( tableStyle: "webgrid-table", headerStyle: "webgrid-header", alternatingRowStyle: "webgrid-alternating-row", mode:…
Thiru
  • 43
  • 1
  • 5
4
votes
2 answers

Get Enum DisplayName in WebGrid

I have a WebGrid that displays a Status enum in one column. There are a couple of enum members that consist of two words and I want to use the enum's DisplayName property rather than the default ToString() representation, e.g. "OnHold" should be…
David Clarke
  • 12,888
  • 9
  • 86
  • 116
4
votes
2 answers

post items of webgrid asp.net mvc3

I have these DTO's public class Header { public int HeaderId{get;set;} public int Description{get;set;} public List HeaderItems{get;set;} } public class HeaderItem { public int HeaderItemId{get;set;} public string…
Aitiow
  • 882
  • 2
  • 9
  • 18
4
votes
2 answers

Webgrid MVC 3 conditional row style

I am using a WebGrid to display a list of items, I like to set the background color of the rows based on a condition. I want to set the background color of the entire row, not just one cell. Any example? thank you
kalu
  • 337
  • 2
  • 9
  • 19
4
votes
1 answer

Webgrid: Maintain Filter after Sorting

I have set up a webgrid and it seems to work fine, allowing me to sort and page. I have added a filter option which also works well however if I filter and then sort the results, the filter is lost and all records are displayed. Here is my Razor…
James
  • 1,979
  • 5
  • 24
  • 52
4
votes
2 answers

Used List as Model in Web Grid at ASP.NET MVC3

I passed List as Model to WebGrid Constructor. @model List @{ var grid = new WebGrid(Model); }
@grid.GetHtml()
I am expecting to get my List of string with grid. But I got length of string. Weird?
ttacompu
  • 873
  • 1
  • 10
  • 15
4
votes
1 answer

MVC3 WebGrid disappears after sorting or paging with a filter

I am having the same issue as this question. I have created a filter that is supposed to work alongside a WebGrid. The filter works for the first page, but if you try to go to a different page or sort the results, the filter is lost. I followed…
user1013571
  • 125
  • 1
  • 7
4
votes
1 answer

ASP.NET MVC3 WebGrid - custom, server-side sorting

Is there a way to override default MVC3 WebGrid sorting behavior to call my controller (which will perform server side sorting and return the data) when sort is called? Thanks for any help!
MattheW
  • 808
  • 11
  • 25
3
votes
1 answer

WebGrid not shown

My View consists of following code @{ List list = new List(); list.Add("1001"); list.Add("1002"); list.Add("1003"); var g = new WebGrid(source:list); g.GetHtml(); } nothing is there other…
bjan
  • 2,000
  • 7
  • 32
  • 64
3
votes
1 answer

MVC WebGrid Set the ID rendered

Using WebGrid from MVC 3 how do i specify the name of the control when rendered i.e. the id of the table when rendered?? var someGrid = new WebGrid(source: Model.Users, defaultSort: "Name", rowsPerPage: 50); At the moment when rendered as a table…
Somedeveloper
  • 817
  • 2
  • 14
  • 31
3
votes
4 answers

MVC3 WebGrid Page/Sort Issue with a CheckBox elsewhere on the page

I have a checkbox on my page, created as such: @Html.CheckBoxFor(x => x.MyBoolValue) Beneath that I have a WebGrid with sorting and paging, but on doing this I get a System.InvalidOperationException: The parameter conversion from type…
pfeds
  • 2,183
  • 4
  • 32
  • 48
3
votes
1 answer

WebGrid: Include information in the row (tr). for example the Id

I am working with the helper Html.WebGrid in MVC3, how I can do to include the data for each TR tag?. I have data in a column, I do not want to show the column, and I need these data are on the TR of the table, and then work with JavaScript. Thank…
andres descalzo
  • 14,887
  • 13
  • 64
  • 115
3
votes
1 answer

Asp.net MVC3 manipulating WebGrid Row

var grid = new WebGrid(source: Model, ...); grid.Column("IsValid", "IsValid", format: (item) => (item.IsValid) ? ? Html.Raw("< src='../../Content//' />") : Html.Raw("< src='../../' />"), style: "testStyle"), grid.Column(header: "Delete",…
DdotP
  • 31
  • 3
3
votes
2 answers

How to add Html inside ASP.NET MVC 3 WebGrid Column Name (Header)

I am unable to add html inside WebGrid column name(at header)? When I add html inside column name then webgrid encodes that. Is this is not possible to add html inside WebGrid column name?
user983443
  • 33
  • 1
  • 1
  • 3
3
votes
1 answer

Paging a webgrid by Model and Count

I've been developing an asp.net mvc 3 application and I'm using webgrid to show tabular data in my view. My question is, how can I page some data by counting how many records I have in the database and show the pager of webgrid in my grid's footer?…
Felipe Oriani
  • 37,948
  • 19
  • 131
  • 194