THEAD

A

Arne

ASP.net can create HTML tables with Datagrid and Table controls. Is there an
ASP.net control that allows me to build an HTML table with a THEAD row?
 
P

Phillip Williams

Hi Arne,

Since the Repeater control is the only Web control that allows you to split
markup tags across the templates. you can write something like this to get a
THEAD and TBODY section:

<asp:Repeater id=Repeater1 runat="server">
<HeaderTemplate>
<table border=1 id="table1">
<THEAD >
<tr>
<th><b>Company</b></td>
<th><b>Symbol</b></td>
</tr>
</THEAD>
</TBODY>
</HeaderTemplate>

<ItemTemplate>
<tr>
<td> <%# DataBinder.Eval(Container.DataItem, "Name") %> </td>
<td> <%# DataBinder.Eval(Container.DataItem, "Ticker") %> </td>
</tr>
</ItemTemplate>

<FooterTemplate>
</TBODY>
</table>
</FooterTemplate>
</asp:Repeater>

You can then style them like this:

<style>
#table1 thead td{
/*style definition for the cell within a thead*/
}
#table1 tbody td{
/*style definition for the cell within a tbody*/
}
</style>
 
P

Phillip Williams

Correction:

The THEAD section should look like that instead:
<THEAD >
<tr>
<th>Company</th>
<th>Symbol</th>
</tr>
</THEAD>
and the equivalent style should be like this:
<style>
#table1 thead th{
/*style definition for the cell within a thead*/
}
#table1 tbody td{
/*style definition for the cell within a tbody*/
}
</style>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,139
Messages
2,570,805
Members
47,356
Latest member
Tommyhotly

Latest Threads

Top