检查年份是否与c#一起飞跃

Cov*_*ove 5 c# sql-server

我对C#很新,所以我的问题可能很愚蠢,但我真的无法通过自己和Google搜索来解决它.我需要检查一年是否飞跃,所以:

<mso:if runat=server condition='<%# DateTime.IsLeapYear(2000)%>'>
Run Code Online (Sandbox Code Playgroud)

工作良好.但我需要从某个地方获取Year,例如MS SQL:

 YEAR(getDate()) AS yarr
Run Code Online (Sandbox Code Playgroud)

...

<mso:if runat=server condition='<%# DateTime.IsLeapYear(<%#Convert.ToInt32(DataBinder.Eval(Container.DataItem, "yarr"))%>)%>'>
Run Code Online (Sandbox Code Playgroud)

错误:

CS1040:预处理程序指令必须显示为一行中的第一个非空白字符

但为什么?在一年之前看不到任何空间.

Adi*_*dil 8

您使用了<%# %>两次嵌套的scriptlet ,删除一个.

condition='<%# DateTime.IsLeapYear(Convert.ToInt32(DataBinder.Eval(Container.DataItem, "yarr")))%>'
Run Code Online (Sandbox Code Playgroud)