Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the point of the TableHeaderRow class

Tags:

.net

asp.net

I've just converted some code from using HtmlTable controls to the web based Table controls and I found that in additional to the TableRow class there is also TableHeaderRow. I foolishly made the assumption based on some half read comments on here that if a row was one of these that it would be put in a thead element in the outputted HTML. It wasn't.

When this didn't work I looked close and noticed that TableHeaderRow seems to have no actual code on it and that the TableSection property of TableRow doesn't care if its a TableHeaderRow or not.

So what is the point of this type? It seems that in practice it is exactly identical to the TableRow class and you still have to set the TableSection property on it to tell it that its a thead row.

Is there a good use case scenario for this? I certainly can't think of one...

Edit for clatification

In my investigations I have used Refactor to look at the code involved. This is how I determined that TableHeaderRow seems to derive from TableRow but not actually implement anythign new.

In the rendering for Table when determining whether to output a thead or not it seems to look purely at the TableSection property. It doesn't care what the actual type of the row is and I can't find a single line of code anywhere that I've looked that would behave differently purely from the type of the row being different.

I'm looking for an actual practical example of how it differs. While I appreciate doc references they don't actually seem to match with the code I'm looking at.

like image 358
Chris Avatar asked Nov 15 '12 12:11

Chris


2 Answers

I wondered the same thing. When I saw the page Creating ASP.NET table header row I realized that I was not setting the TableSection property as I should:

hRow.TableSection = Web.UI.WebControls.TableRowSection.TableHeader

It made the <thead> element to apear in the output html.

like image 137
LAFP Avatar answered Oct 20 '22 01:10

LAFP


According to this MSDN entry:

This class supports displaying tables on devices with a limited screen size. On these devices, a table with many columns and rows must be rendered across multiple pages. Adding a TableHeaderRow to a Table control allows you to specify a heading row that is rendered as the first row on each page that displays a view of the table.

I would infer from this that TableRow doesn't expose this kind of support.

like image 44
Jamie Dixon Avatar answered Oct 20 '22 01:10

Jamie Dixon