I am very new to C#, so my question may be silly but I realy can't solve it by myself & googling. I need to check if year is leap, so:
<mso:if runat=server condition='<%# DateTime.IsLeapYear(2000)%>'>
works fine. But I need to get Year from somewhere, e.g. MS SQL:
YEAR(getDate()) AS yarr
...
<mso:if runat=server condition='<%# DateTime.IsLeapYear(<%#Convert.ToInt32(DataBinder.Eval(Container.DataItem, "yarr"))%>)%>'>
Error:
CS1040: Preprocessor directives must appear as the first non-whitespace character on a line
But why? Don't see any space before year.
You used scriptlet <%# %>
twice which are nested, remove one.
condition='<%# DateTime.IsLeapYear(Convert.ToInt32(DataBinder.Eval(Container.DataItem, "yarr")))%>'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With