How do I get Gridview to render THEAD?


Question

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.

1
109
1/14/2010 1:49:57 PM

Accepted Answer

This should do it:

gv.HeaderRow.TableSection = TableRowSection.TableHeader;
185
9/30/2017 12:25:00 PM

I use this in OnRowDataBound event:

protected void GridViewResults_OnRowDataBound(object sender, GridViewRowEventArgs e) {
    if (e.Row.RowType == DataControlRowType.Header) {
        e.Row.TableSection = TableRowSection.TableHeader;
    }
}

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon