How do I get the GridView
control to render the <thead>
<tbody>
tags? I know .UseAccessibleHeaders
makes it put <th>
instead of <td>
, but I cant get the <thead>
to appear.
views:
1232answers:
2
+11
A:
This should do it...
gv.HeaderRow.TableSection = TableRowSection.TableHeader;
Phil Jenkins
2008-11-21 15:34:00
I just found that and was about to answer myself, thanks anyway, spot on :)
Andrew Bullock
2008-11-21 15:35:50
The `HeaderRow` property will be `null` until the `GridView` has been data bound, so make sure to wait until databinding has occurred before running the above line of code.
bdukes
2009-07-17 14:47:07
+1
A:
The code in the answer needs to go in Page_Load or GridView_PreRender. I put it in a method that was called after Page_Load and got a NullReferenceException.
You can also put in `DataBound` event. `grid.DataBound += (s, e) => { grid.HeaderRow.TableSection = TableRowSection.TableHeader; };`
BrunoLM
2010-08-12 11:53:13