Wednesday, March 28, 2012

List View Template-Table layout

Is it possible to set the template to generate table rows?Yes. There's 1 gotcha though: you need to define a tbody as well. So, the template for tables should look like:

<table runat="server">
<tbody>
<tr id="itemTemplate" runat="server">... </tbody>
</table>

Wilco,

I am having issues with this too, getting unknown runtime errors. Do you have a working example?

My code (probably far from what it should be):

<tablecellspacing="0"cellpadding="0"frame="box"style="border-collapse: collapse;">
<tbody>
<atlas:ListViewID="listEmails"runat="server"ItemTemplateControlID="itemTemplate"CssClass="list"ItemCssClass="row"AlternatingItemCssClass="altrow">
<LayoutTemplate>
<trid="itemTemplate"runat="server">
<tdid="itemTemplateColumn"runat="server">
<atlas:LabelID="lblAddress"runat="server">
<Bindings>
<atlas:BindingDataPath="Address"Property="text"/>
</Bindings>
</atlas:Label>
</td>
<td>
...
</td>
</tr>
</LayoutTemplate>
</atlas:ListView>
</tbody>
</table>

Thx
dB.


Got it. The table and tbody have to go inside the LayoutTemplate. It's a little confusing ...

<atlas:ListViewID="listEmails"runat="server"ItemTemplateControlID="itemTemplate"CssClass="list"ItemCssClass="row"AlternatingItemCssClass="altrow">
<LayoutTemplate>
<tablecellspacing="0"cellpadding="0"frame="box"style="border-collapse: collapse;">
<tbodyid="trBody"runat="server">
<trid="itemTemplate"runat="server">
<td>
<atlas:LabelID="lblAddress"runat="server">
<Bindings>
<atlas:BindingDataPath="Address"Property="text"/>
</Bindings>
</atlas:Label>
</td>
<td>
...
</td>
</tr>
</tbody>
</table>
</LayoutTemplate>
</atlas:ListView>


Please look at my previous post. The sample code disappeared cause the HTML in my message was not encoded. I tried to encode it myself, but it looks like the forum is a bit screwed up.

Anyway, as you can see the table/tbody should be inside the template. Also note which tags need to runat server...

No comments:

Post a Comment