Salutations!ASP.NET GridView Newbie Questions à propos de TFOOT et TH
J'apprends toujours sur le contrôle GridView et j'en ai un lié à un ObjectDataSource. Ma forme Web ressemble à ceci:
<asp:GridView ID="ourGrid" runat="server" DataSourceID="ourDataSource" onrowdatabound="ourGrid_RowDataBound"
HeaderStyle-CssClass="header_style" AlternatingRowStyle-CssClass="altrow_style"
ShowFooter="true">
<columns>
<asp:BoundField DataField="Name" HeaderText="Full Name" />
<asp:BoundField DataField="Gender" HeaderText="Gender" />
<asp:BoundField DataField="BirthYear" HeaderText="Year of Birth" />
<asp:BoundField DataField="JoinDate" HeaderText="Date Joined" HtmlEncode="false" DataFormatString="{0:d}" />
</columns>
</asp:GridView>
<asp:ObjectDataSource ID="ourDataSource" runat="server" SelectMethod="GetTopUsers" TypeName="Acme.Model.OurNewObject">
</asp:ObjectDataSource>
Il génère actuellement le balisage suivant:
<table cellpadding="0" cellspacing="0" summary="">
<thead>
<tr style="header_style">
<th scope="col">Full Name</th>
<th scope="col">Gender</th>
<th scope="col">Year of Birth</th>
<th scope="col">Date Joined</th>
</tr>
</thead>
<tfoot>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</tfoot>
<tbody>
<tr>
<td>John Smith</td>
<td>Male</td>
<td>1967</td>
<td>17-6-2007</td>
</tr>
<tr class="AspNet-GridView-Alternate altrow_style">
<td>Mary Kay</td>
<td>Female</td>
<td>1972</td>
<td>15-11-2007</td>
</tr>
<tr>
<td>Bill Jones</td>
<td>Male</td>
<td>1970</td>
<td>23-2-2007</td>
</tr>
</tbody>
</table>
Il y a quelques éléments HTML que je voudrais ajouter à la balise de table que ce contrôle GridView va générer. Pour commencer, j'ai besoin TFOOT pour ressembler à ceci:
<tfoot>
<tr>
<td colspan="4">
<div>
<a class="footerlink_style" title="Newest Members" href="#">Newest Members</a>
<a class="footerlink_style" title="Top Posters" href="#">Top Posters</a>
</div>
</td>
</tr>
</tfoot>
Les liens ne contiennent des informations databound, mais seront probablement des contrôles Hyperlien. Y a-t-il un moyen de le spécifier au moment du design?
De même, pour le THEAD, est-il possible de spécifier des styles séparés pour chaque en-tête de colonne comme ceci dans le GridView?
<thead>
<tr style="header_style">
<th scope="col" style="col1_style">Full Name</th>
<th scope="col" style="col2_style">Gender</th>
<th scope="col" style="col3_style">Year of Birth</th>
<th scope="col" style="col4_style">Date Joined</th>
</tr>
</thead>
Enfin, est-il possible de spécifier l'attribut de résumé de la table comme ceci?
<table cellpadding="0" cellspacing="0" summary="Here is a list of users">
Merci d'avance.
J'ai ajouté un exemple de travail complet sur une seule page. HTH. – Kev
Merci pour les pastebins, je vais jeter un coup d'oeil plus tard aujourd'hui quand je reçois un bon bloc de temps libre. – Kev