Using DataList - table and headers

M

Mirek Endys

Hello,

Im often use DataList for viewing and editing datas. For better layout
controling, I create a table in the template and there I put other controls
or binding data into table cells.

Sometimes, I would use the HeaderTemplate as header of my table (in
ItemTemplate).
How to do it? How to make the table columns in HeaderTemplate linked to
table columns in ItemTemplate?

Thanks.

Mirek.
 
E

Eliyahu Goldin

Mirek,

Wrap the table around the datalist like this:
<table>
<asp:DataList ...>
<HeaderTemplate>
<tr>...</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>...</tr>
</ItemTemplate>
</asp:DataList>
</table>

Eliyahu
 
G

Guest

The datalist exposes a property named RepeatLayout which can have a value of
either Table or Flow. To experiment with both outcome try this sample from
the MSDN:
http://msdn.microsoft.com/library/d...webcontrolsdatalistclassrepeatlayouttopic.asp

The RepeatLayout=Flow would produce a span for each datalist item being
rendered on the browser. This would prevent you from enclosing the entire
datalist in a <Table> (where the header is only a Tablerow and each item in
the body is another TableRow as the repeater would do).

Therefore you should use CSS to align the columns within different tables by
specifying the TD width values as I did in this sample:
http://www.societopia.net/samples/DataList_Hierarchy.aspx
 

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

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top