Here is a way to create jQuery Mobile's responsive tables with an ASP.NET gridview.
ASP.NET (Reflow Example)
Protected Sub gv_DataBound(ByVal sender As Object, ByVal e As EventArgs) Handles gv.DataBound
gv.HeaderRow.TableSection = TableRowSection.TableHeader
gv.Attributes.Add("data-role", "table")
gv.Attributes.Add("data-mode", "reflow")
Dim headerCells = gv.HeaderRow.Cells
headerCells(3).Attributes.Add("data-priority", "2")
headerCells(4).Attributes.Add("data-priority", "2")
End Sub
QUESTION
When my gridview returns no results I receive error : Object reference not set to an instance of an object.
I presume this is because the gridview has nothing to bind to however the gridview still renders as a table.
Can anyone conceive why this may be occuring and how it can be fixed?
THE FIX
To fix this be sure to add ShowHeaderWhenEmpty="True" to your gridview to ensure the thead tag is still rendered when empty.