I must be doing something wrong here but I can’t find an easy way to get this to work.
Imagine the following code:
<asp:RadioButtonList ID="MyRadioButtonList" runat="server">
<asp:ListItem Value="<%= CompanyName.SystemName.Constants.PaymentFrequency.FREQUENT.ToString() %>" Text="Yes" Selected="True"></asp:ListItem>
<asp:ListItem Value="<%= CompanyName.SystemName.Constants.PaymentFrequency.ONCE.ToString() %>" Text="No, Just do this once"></asp:ListItem>
</asp:RadioButtonList>
But it doesn’t compile the statement before it renders the page. So if I get the selected value of this radiobuttonlist it contains something like “<%= Compan… %>” instead of what my constant defines.
What is the correct syntax for this?
I don’t know why exactly (I didn’t manage to find a reference) but the
<%= %>syntax doesn’t work when you are setting the Value or the Text of a ListItem, in ASPX mark-up.You could instead do it from code-behind, like: