alternate row color in DataList

patlat

New Member
Hi,<BR>How do you alternate row color on a dataList? I'm using Header and Item Templates. I can't figure out how to place the AlternatingItemStyle tag. Has anyone done this?<asp:DataList id="DataList1" runat="server" AlternatingItemStyle-BackColor="LightGrey"><BR><BR>Yes? No?<BR>That's what I've tried. Doesn't seem to work. I tried adding the AlternatingItemStyle tag as a seperate item and get a parsing error.<BR><BR>Literal content ('<AlternatingItemStyle-BackColor="black" />') is not allowed within a 'System.Web.UI.WebControls.DataList'.<BR> <BR>I'm curious if anyone has actually got it to work (on a Datalist not grid)<BR><BR>ThanksI get alternating items with every other one having a grey background: <BR><BR><asp:DataList id="DataList1" runat="server" AlternatingItemStyle-BackColor="#cccccc"><BR> <ItemTemplate><BR> <asp:Label ID="lblTest" Runat="server"><BR> <%# Container.dataItem("userName") %><BR> </asp:Label> <BR> </ItemTemplate><BR> </asp:DataList><BR>hmmmm.<BR>My ItemTemplate consists of mutiple cells. (A table format) If I remove the cells then it works as expected. With the table cells it fails. (appears to put the alternate color in one random cell.)<BR><BR>Thanks
 
Back
Top