2014年7月13日 星期日

[RESOLVED] Alternating Row Color List View


Hi I have a list view created manually (not from visual studio wizards) that I dont know how to add an alternating row color to it. Its a bit tricky becasue each record I get back generates two table rows (although I can change if needed to achive the alt
row color). Here is my current code. Help appreciated. Thanks:








We didn't find anything. Please try again.















Label
Wine

Store






<%# Eval("WineName")%>


<%# Eval("StoreName") %>







Price Range:<%# Eval("PriceRange")%>


<%# Eval("Address")%>


Map it








 



There is the AlternatingItemTemplate property that can be used to set the alternating row




...




...


http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview.alternatingitemtemplate.aspx


Alternatively you can use another way. From within any template, you have access to the current index of the row within the whole data set, using Container.DataItemIndex, and within the currently displayed items, using Container.DisplayIndex. This gives us an easy way to alternate styles:



">
...


Just define the even and odd classes in your stylesheet and you're pretty much done.


Hope this helps.


沒有留言:

張貼留言