Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 418
  • Last Modified:

Need to convert this code to work in C# ASP.Net

I've used this line of code in my vb.net asp sites to alternate row styles in a table generated by a repeater. I'd like to use it in my C# asp sites but I can't seem to get the syntax correct. Does anyone know the correct syntax? Thanks

class='<%# IIf(Container.ItemIndex Mod 2 = 0, "repeaterOddRow", "repeaterEvenRow") %>'
0
Bob Hoffman
Asked:
Bob Hoffman
  • 2
1 Solution
 
Chad SmithSoftware EngineerCommented:
class='<%# Container.ItemIndex % 2 = 0 ? "repeaterOddRow":"repeaterEvenRow") %>'
0
 
Chad SmithSoftware EngineerCommented:
Sorry missed the extra =

class='<%# Container.ItemIndex % 2 == 0 ? "repeaterOddRow":"repeaterEvenRow") %>'
0
 
Bob HoffmanDeveloperAuthor Commented:
added a left parenthesis before "Container".... work great! Thanks knight00

class='<%# (Container.ItemIndex % 2 == 0 ? "repeaterOddRow":"repeaterEvenRow") %>'
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now