---
title: "WebGrid in MVC"  
description: "In this blog I’m trying to explain the concept of WebGrid using MVC.  WebGrid is a predefine tool for web, WebGrid will Display the data on a web page"  
author: "Vijay Shukla"  
published: 2013-09-27  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/590/webgrid-in-mvc  
category: "asp.net mvc"  
tags: ["asp.net mvc"]  
reading_time: 3 minutes  

---

# WebGrid in MVC

In this blog I’m trying to [explain the concept](https://www.mindstick.com/forum/159605/explain-the-concept-of-unique-key-violation-error) of WebGrid using MVC.\

WebGrid is a predefine tool for web, WebGrid will Display the data on a [web page](https://www.mindstick.com/forum/718/sql-server-report-alignment-to-center-of-web-page) in a [tabular format](https://www.mindstick.com/forum/34668/how-to-embed-tabular-format-data-in-outlook-using-asp-dot-net-mvc) (an HTML table element). We can do easily shorting (Ascending or Descending) and paging for [our data](https://yourviews.mindstick.com/view/70567/data-protection-bill-understanding-our-data). For using WebGrid in any [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) use the System.Web.Helpers.WebGrid [Namespace](https://www.mindstick.com/articles/12552/namespace)

##### WebGrid Properties

\

##### AjaxUpdateCallback

Gets the name of the [JavaScript function](https://www.mindstick.com/forum/2090/send-data-from-asp-dot-net-code-behind-to-a-javascript-function) to call after the HTML element that is associated with the WebGrid instance has been updated in response to an Ajax update request.

##### AjaxUpdateContainerId

Gets the value of the HTML id attribute that marks an HTML element on the web page that gets dynamic Ajax updates that are associated with the WebGrid instance.

##### CanSort

Gets a value that indicates whether the WebGrid instance supports sorting.

##### ColumnNames

Gets a [collection](https://www.mindstick.com/articles/1718/collections-in-java) that contains the name of each data column that is bound to the WebGrid instance.

##### FieldNamePrefix

Gets the prefix that is applied to all query-string fields that are associated with the WebGrid instance.

##### HasSelection

Gets a value that indicates whether a row in the WebGrid instance is selected.

##### IsAjaxEnabled

Returns a value that indicates whether the WebGrid instance can use Ajax calls to refresh the display.

##### PageCount

Gets the number of pages that the WebGrid instance contains.

##### PageFieldName

Gets the [full name](https://www.mindstick.com/interview/33973/how-to-split-the-full-name-into-firstname-and-lastname-in-sql-server) of the query-string field that is used to specify the current page of the WebGrid instance.

##### PageIndex

Gets or sets the index of the current page of the WebGrid instance.

##### Rows

Gets a list that contains the rows that are on the current page of the WebGrid instance after the grid has been sorted.

##### RowsPerPage

Gets the number of rows that are displayed on each page of the WebGrid instance.

##### SelectedIndex

Gets or sets the index of the selected row relative to the current page of the WebGrid instance.

##### SelectedRow

Gets the currently selected row of the WebGrid instance.

##### SelectionFieldName

Gets the full name of the query-string field that is used to specify the selected row of the WebGrid instance.

##### SortColumn

Gets or sets the name of the data column that the WebGrid instance is sorted by.

##### SortDirection

Gets or sets the direction in which the WebGrid instance is sorted.

##### SortDirectionFieldName

Gets the full name of the query-string field that is used to specify the sort direction of the WebGrid instance.

##### SortFieldName

Gets the full name of the query-string field that is used to specify the name of the data column that the WebGrid instance is sorted by.

##### TotalRowCount

Gets the total number of rows that the WebGrid instance contains.

##### WebGrid Methods

##### Bind

Binds the specified data to the WebGrid instance.

##### Columns

Returns an array that contains the specified WebGridColumn instances.

##### GetContainerUpdateScript

Returns a JavaScript statement that can be used to update the HTML element that is associated with the WebGrid instance on the specified web page.

##### GetHtml

Returns the HTML markup that is used to render the WebGrid instance and using the specified paging options.

##### GetPageUrl

Returns a URL that can be used to display the specified data page of the WebGrid instance.

##### GetSortUrl

Returns a URL that can be used to sort the WebGrid instance by the specified column.

##### Pager

Returns the HTML markup that is used to provide the specified paging support for the WebGrid instance.

##### Example:-

For example Read [WebGrid in ASP.NET MVC4](https://www.mindstick.com/Blog/584/WebGrid) Blog.

---

Original Source: https://www.mindstick.com/blog/590/webgrid-in-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
