WebGrid Constructor

Initializes a new instance of the WebGrid class.

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

Syntax

'Declaration
Public Sub New ( _
    source As IEnumerable(Of Object), _
    columnNames As IEnumerable(Of String), _
    defaultSort As String, _
    rowsPerPage As Integer, _
    canPage As Boolean, _
    canSort As Boolean, _
    ajaxUpdateContainerId As String, _
    ajaxUpdateCallback As String, _
    fieldNamePrefix As String, _
    pageFieldName As String, _
    selectionFieldName As String, _
    sortFieldName As String, _
    sortDirectionFieldName As String _
)
'Usage
Dim source As IEnumerable(Of Object)
Dim columnNames As IEnumerable(Of String)
Dim defaultSort As String 
Dim rowsPerPage As Integer 
Dim canPage As Boolean 
Dim canSort As Boolean 
Dim ajaxUpdateContainerId As String 
Dim ajaxUpdateCallback As String 
Dim fieldNamePrefix As String 
Dim pageFieldName As String 
Dim selectionFieldName As String 
Dim sortFieldName As String 
Dim sortDirectionFieldName As String 

Dim instance As New WebGrid(source, _
    columnNames, defaultSort, rowsPerPage, _
    canPage, canSort, ajaxUpdateContainerId, _
    ajaxUpdateCallback, fieldNamePrefix, _
    pageFieldName, selectionFieldName, _
    sortFieldName, sortDirectionFieldName)
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
)
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
)
new : 
        source:IEnumerable<Object> * 
        columnNames:IEnumerable<string> * 
        defaultSort:string * 
        rowsPerPage:int * 
        canPage:bool * 
        canSort:bool * 
        ajaxUpdateContainerId:string * 
        ajaxUpdateCallback:string * 
        fieldNamePrefix:string * 
        pageFieldName:string * 
        selectionFieldName:string * 
        sortFieldName:string * 
        sortDirectionFieldName:string -> WebGrid
public function WebGrid(
    source : IEnumerable<Object>, 
    columnNames : IEnumerable<String>, 
    defaultSort : String, 
    rowsPerPage : int, 
    canPage : boolean, 
    canSort : boolean, 
    ajaxUpdateContainerId : String, 
    ajaxUpdateCallback : String, 
    fieldNamePrefix : String, 
    pageFieldName : String, 
    selectionFieldName : String, 
    sortFieldName : String, 
    sortDirectionFieldName : String
)

Parameters

  • 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.

See Also

Reference

WebGrid Class

System.Web.Helpers Namespace