How to setup ASP.NET GridView with jQuery DataTables

Michael Roma on Nov 25, 2012

The following code is needed in the Page_PreRender event to allow an ASP.NET GridView to be used with the jQuery DataTables library ( This will render thead tags for the column row.

’ Page pre render
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender

    ‘ support for jquery datatables
    If grid.Rows.Count > 0 Then
        grid.UseAccessibleHeader = True
        grid.HeaderRow.TableSection = TableRowSection.TableHeader
    End If

End Sub