Reputation:
This is my DataList code , I define a table in headertemplate and close it in footerTemplate.
The problem is with AlternatingItemStyle and ItemStyle that they don't effect.
If i move the table defenition inside <ItemTemplate>
it does work.
<asp:DataList ID="DataList1" runat="server" DataKeyField="ProductID"
DataSourceID="ObjectDataSource1" EnableViewState="False"
onitemdatabound="DataList1_ItemDataBound" Width="474px">
<AlternatingItemStyle CssClass="AlternatingRowStyle" />
<ItemStyle CssClass="RowStyle" />
<HeaderTemplate>
<table cellspacing="0" cellpadding="0">
</HeaderTemplate>
<ItemTemplate>
<div id="Comment">
<tr>
<div id="Data1">
<td>
<asp:CheckBox ID="CheckBox1" runat="server" />
</td>
<td>
<asp:CheckBox ID="CheckBox2" runat="server" />
</td>
<td>
<asp:LinkButton ID="LinkButton1" runat="server" Text='<%# Eval("CategoryName") %>' />
</td>
</div>
</tr>
<tr>
<td></td>
<td></td>
<td>
<asp:Label ID="CategoryNameLabel" runat="server" Text="dfgfdgdg" />
</td>
</tr>
</div>
</ItemTemplate>
<FooterTemplate> </table></FooterTemplate>
</asp:DataList>
Upvotes: 3
Views: 11955
Reputation: 7994
Lupital, from my recollection, the DataList control will generate the table tags for you, you don't need to specify them in the header and footer.
For example:
<asp:DataList id="ItemsList"
BorderColor="black"
CellPadding="0"
CellSpacing="0"
RepeatDirection="Vertical"
RepeatLayout="Table"
BorderWidth="0"
runat="server">
This should accomplish what you are looking to do with setting up the 'outer' table properties of your table of items.
Hopefully, that should solve your alternating style problem.
Upvotes: 3