code_junkie

Alternating Item Style

Nov 11th, 2011
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. <div class="MyImage"><img src="" /></div>
  2. <div class="MyDescription">Blah...Blah...</div>
  3.  
  4. .MyItemStyle .MyImage {width:49%; float:left;}
  5. .MyItemStyle .MyDescription {width:49%; float:right;}
  6.  
  7. .MyAltItemStyle .MyImage {width:49%; float:right;}
  8. .MyAltItemStyle .MyDescription {width:49%; float:left;}
  9.  
  10. ItemStyle = "MyItemStyle"
  11. AlternatingItemStyle = "MyAltItemStyle"
  12.  
  13. <asp:Repeater runat="server" ID="Repeater1" OnItemDataBound="Repeater1_ItemDataBound" />
  14.  
  15. public void Repeater1_ItemDataBound(Object sender, RepeaterItemEventArgs e)
  16. {
  17. if (e.Item.ItemType == ListItemType.AlternatingItem)
  18. {
  19. // e.Item is an alternating item
  20. }
  21. else
  22. {
  23. }
  24. }
  25.  
  26. <asp:GridView>
  27. <Columns>
  28. <asp:TemplateColumn>
  29. <%# Container.DataItemIndex % 2 == 0 ? Eval("Image") : Eval("Desc") %>
  30. </asp:TemplateColumn>
  31. <asp:TemplateColumn>
  32. <%# Container.DataItemIndex % 2 == 0 ? Eval("Desc") : Eval("Image") %>
  33. </asp:TemplateColumn>
  34. </Columns>
  35. </asp:GridView>
  36.  
  37. <asp:GridView>
  38. <Columns>
  39. <asp:TemplateColumn>
  40. <uc:Image Data='<%# Eval("Image") %>'
  41. Visible='<%# Container.DataItemIndex % 2 == 0 %>' />
  42. <uc:Description Data='<%# Eval("Description") %>'
  43. Visible='<%# Container.DataItemIndex % 2 != 0 %>' />
  44. </asp:TemplateColumn>
  45. <asp:TemplateColumn>
  46. <uc:Image Data='<%# Eval("Image") %>'
  47. Visible='<%# Container.DataItemIndex % 2 != 0 %>' />
  48. <uc:Description Data='<%# Eval("Description") %>'
  49. Visible='<%# Container.DataItemIndex % 2 == 0 %>' />
  50. </asp:TemplateColumn>
  51. </Columns>
  52. </asp:GridView>
Add Comment
Please, Sign In to add comment