Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking if year is leap with c#

Tags:

c#

sql-server

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.

like image 576
Cove Avatar asked Feb 26 '16 06:02

Cove


1 Answers

You used scriptlet <%# %> twice which are nested, remove one.

condition='<%# DateTime.IsLeapYear(Convert.ToInt32(DataBinder.Eval(Container.DataItem, "yarr")))%>'
like image 177
Adil Avatar answered Sep 24 '22 11:09

Adil