I have an ASP ListView which I am using to display some pivoted information (across years) in a table. Currently I have the ListView templates defined as:
<LayoutTemplate>
<table id="listViewTable" class="tableData">
<tr class="rowHeader">
<td style="text-align: left;">Rank / Equivalent Rank</td>
<td>2004</td>
<td>2005</td>
<td>2006</td>
<td>2007</td>
<td>2008</td>
<td>2009</td>
<td>2010</td>
</tr>
<tr id="itemPlaceholder" runat="server"></tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<%#addListViewSectionHeaderRow()%>
<%#addListViewRankValueCell()%>
<td class="cellNumeric"><%#formatNumber(Eval("2004"))%></td>
<td class="cellNumeric"><%#formatNumber(Eval("2005"))%></td>
<td class="cellNumeric"><%#formatNumber(Eval("2006"))%></td>
<td class="cellNumeric"><%#formatNumber(Eval("2007"))%></td>
<td class="cellNumeric"><%#formatNumber(Eval("2008"))%></td>
<td class="cellNumeric"><%#formatNumber(Eval("2009"))%></td>
<td class="cellNumeric"><%#formatNumber(Eval("2010"))%></td>
</tr>
</ItemTemplate>
As you can see in the Eval()
statements, the columns in the query behind the scenes already selects the years as they are displayed on the page.
How do I just display the column names from the query in the LayoutTemplate
instead of the hard-coded values I have? I thought this would be easy to find in documentation somewhere, but I can't find anything...but maybe I'm not looking in the right place...
Thanks!
Edit: I guess I also have a problem with defining the actual years in the Eval()
statements. I want to get this as automatic as possible so when, for example, 2011 data appears, the page reflects only 2005-2011 years. Maybe I'm doing something fundamentally wrong with that goal in mind?