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
2
votes
0 answers

ASP.NET MVC Select and reorder columns in WebGrid

I have following View code: @model IEnumerable @{ var grid = new WebGrid(source: Model, defaultSort:"Route ID", rowsPerPage: 50); } @grid.GetHtml() And I'd like to select columns in my custom order. How can I do that?
tomwesolowski
  • 956
  • 1
  • 11
  • 27
2
votes
1 answer

Embed image in asp.net MVC web grid column header

Is there any way to embed a image in asp.net MVC web grid column? I like to display a information icon beside the webgrid column header. @if(grid != null) { @grid.GetHtml(tableStyle:"table table-striped",headerStyle:"webgrid-header…
Vin05
  • 587
  • 4
  • 12
  • 30
2
votes
1 answer

Webgrid not refreshing after delete MVC

I am deleting a row in my webgrid , and redirecting to my GET index as normal after delete. However as expected my view is showing the old deleted row still in the grid. I know this is by design and i should be able to set the Modelstate to clear ,…
Alicia
  • 1,152
  • 1
  • 23
  • 41
2
votes
0 answers

In Asp.net MVC 4 multiple inline row update in single click using WebGrid

I wants to do multiple inline rows update when click on Update button outside the Grid. Below is the url of sample project I am referring. http://www.c-sharpcorner.com/UploadFile/cd7c2e/create-an-editable-webgrid-in-mvc4-to-implement-crud-operati/…
Nijith
  • 25
  • 1
  • 9
2
votes
1 answer

Pass webgrid data back to controller via post asp.net mvc

I am new to MVC and would like to know, how to submit whole grid data on submit button click to controller at once using viewmodel. In View @model prjMVC4Training.Models.BookViewModel @{ ViewBag.Title = "Index"; var categories =…
user3322513
  • 21
  • 1
  • 3
2
votes
1 answer

Using WebGrid to show a list of email addresses (strings) - ASP.Net MVC4

I am declaring a WebGrid as follows: @{ WebGrid grid = null; if (Model.EmailAddressesOfChosenClient.Count() != 0) { grid = new WebGrid(Model.EmailAddressesOfChosenClient, ajaxUpdateContainerId: "gridContent"); …
user3041439
  • 153
  • 2
  • 2
  • 15
2
votes
1 answer

WebGrid control issue in Mvc4

I am new in MVC and I'm trying to use WebGird control in my demo application I do some task like below:- HomeController public ActionResult Index() { List listStudent = new List(); …
Jay Shukla
  • 782
  • 1
  • 13
  • 24
2
votes
2 answers

Sql select query is only returning last row n times

I'm using webmatrix. My home server is Ubuntu/mono/nginx/fastcgi. My code is simple. I have a MySql database with a table that contains 4 test records. @{ var db = Database.Open("wra"); var sql = "SELECT * FROM Clients"; …
2
votes
1 answer

Webgrid Pagination and Sorting not working

I have my webgrid in a partial page as follows. From the following page I updates my grid in a partial view, through an ajax call. @using (Html.BeginForm("Manage", "Book",FormMethod.Get, new { @id = "frmBGrid" })) {
TBA
  • 1,077
  • 5
  • 41
  • 80
2
votes
1 answer

Webmatrix webgrid not allowing to change rowsPerPage using Razor

I have the following code, I have a page that looks like this: I want to be able to choose the number of rows per page but I keep getting an error that says: "CS1502: The best overloaded method match for…
Alexandra
  • 65
  • 1
  • 2
  • 13
2
votes
1 answer

Show/Hide Column header in webgrid dynamically

I'm displaying Dynamically selected table Columns using WebGrid i want to hide the column which is not selected.how can i hide the Column header dynamically? I'm using Following webgrid.
@{ var grid = new…
user2514925
  • 931
  • 8
  • 33
  • 56
2
votes
2 answers

two row header in mvc3 WebGrid

Is there any way to have a two row header in a WebGrid ? I looked for a way to do custom rendering for the header or for a way to only render the body of the table (without the table tags), but I couldn't find anything. I would like to create a…
user365268
2
votes
1 answer

How to populate a WebGrid cell with a collection of ActionLinks

I have a Model like so: class Model { public String Text { get; set; } public AnotherType[] Values { get; set; } } And a View that takes an IEnumerable that I am displaying in a WebGrid using Razor and asp.net MVC 4. So far I…
DaveShaw
  • 52,123
  • 16
  • 112
  • 141
2
votes
0 answers

How to use foreach inside webgrid + MVC 3

I have webgrid as below in MVC:how to show list of values in a single row in column in webgrid.I am using foreach inside webgrid column but it is unrecognized Col1 Col2 Col3 --------------- 1 | zzz | t | xxx | | yyy…
Sameer More
  • 589
  • 1
  • 6
  • 13
2
votes
2 answers

Razor multiline syntax for grid column format

I have a WebGrid that I am trying to define in an MVC4 razor view. I would like to define a column format using multiple lines for readability. The following works, with the format on one line: @grid.GetHtml( columns: grid.Columns( …
egbrad
  • 2,387
  • 2
  • 23
  • 27