WebGrid Constructor

Initializes a new instance of the WebGrid class.

Namespace:  System.Web.Helpers
Assembly:  System.Web.Helpers (in System.Web.Helpers.dll)

public WebGrid(
	IEnumerable<Object> source,
	IEnumerable<string> columnNames,
	string defaultSort,
	int rowsPerPage,
	bool canPage,
	bool canSort,
	string ajaxUpdateContainerId,
	string ajaxUpdateCallback,
	string fieldNamePrefix,
	string pageFieldName,
	string selectionFieldName,
	string sortFieldName,
	string sortDirectionFieldName
)

Parameters

source
Type: System.Collections.Generic.IEnumerable<Object>
The data to display.
columnNames
Type: System.Collections.Generic.IEnumerable<String>
A collection that contains the names of the data columns to display. By default, this value is auto-populated according to the values in the source parameter.
defaultSort
Type: System.String
The name of the data column that is used to sort the grid by default.
rowsPerPage
Type: System.Int32
The number of rows that are displayed on each page of the grid when paging is enabled. The default is 10.
canPage
Type: System.Boolean
true to specify that paging is enabled for the WebGrid instance; otherwise false. The default is true.
canSort
Type: System.Boolean
true to specify that sorting is enabled for the WebGrid instance; otherwise, false. The default is true.
ajaxUpdateContainerId
Type: System.String
The value of the HTML id attribute that is used to mark the HTML element that gets dynamic Ajax updates that are associated with the WebGrid instance.
ajaxUpdateCallback
Type: System.String
The name of the JavaScript function that is called after the HTML element specified by the AjaxUpdateContainerId property has been updated. If the name of a function is not provided, no function will be called. If the specified function does not exist, a JavaScript error will occur if it is invoked.
fieldNamePrefix
Type: System.String
The prefix that is applied to all query-string fields that are associated with the WebGrid instance. This value is used in order to support multiple WebGrid instances on the same web page.
pageFieldName
Type: System.String
The name of the query-string field that is used to specify the current page of the WebGrid instance.
selectionFieldName
Type: System.String
The name of the query-string field that is used to specify the currently selected row of the WebGrid instance.
sortFieldName
Type: System.String
The name of the query-string field that is used to specify the name of the data column that the WebGrid instance is sorted by.
sortDirectionFieldName
Type: System.String
The name of the query-string field that is used to specify the direction in which the WebGrid instance is sorted.

  • Medium trust for the immediate caller. This member can be used by partially trusted code.
Show: