Changing the CSS class of an element at runtime
Inside the ItemTemplate repeater is:
<tr class="class1">
</tr>
I want this class to be changed to "class2" according to the evaluation that is limited to this repeater, Eval ("Locked").
If blocked == true class = "class1" else class = "class2", how can I do this in a simple way?
(in the code behind this complicated one)
Really simple, just put the serveride tag:
<asp:Repeater ID="yourRepeater" runat="server">
<ItemTemplate>
....
<tr class='<%# Convert.ToBoolean(Eval("Locked")) ? "class1" : "class2" %>'>
....
</tr>
....
</ItemTemplate>
</asp:Repeater>
UPDATE: Thanks Kobe, I skipped Convert.ToBoolean () :)