I'm trying to make an inline IF statement inside an asp: Repeater control to add a class to the first element, but I can't figure out how to figure it out.
Basically, the code that I have now that does not work, but should give an idea of what I'm trying to do, looks like this.
<asp:Repeater ID="rptrTabRepeater" runat="server">
<ItemTemplate>
<div class="tab <%= If Container.ItemIndex = 0 Then %>highlight<% End If%>">
'Other stuff here
</div>
</ItemTemplate>
</asp:Repeater>
I tried to use the event OnItemDataBound, but the delegate interface cannot return a value. If I'm going to do something using a function with a code code, I just need to be an “echo” function that was not quite sure how to get the index of the element in the function behind the code. If I could do something inline, as in my example, this would be the best solution for me.
Any better solutions are welcome. Thank!
EDIT: Compilation error I get:
Compiler Error Message: BC30201: Expression expected.
source
share