这是我的DataList代码,我在headertemplate中定义一个表,然后在footerTemplate中将其关闭.
问题在于AlternatingItemStyle和ItemStyle无效.
如果我将表定义移到< ItemTemplate>中,它确实有效.
<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>
最佳答案