C# 用c检查年份是否为闰年#

C# 用c检查年份是否为闰年#,c#,sql-server,C#,Sql Server,我对C#很陌生,所以我的问题可能很傻,但我真的不能自己解决它&谷歌。我需要检查年份是否为闰年,因此: <mso:if runat=server condition='<%# DateTime.IsLeapYear(2000)%>'> <mso:if runat=server condition='<%# DateTime.IsLeapYear(<%#Convert.ToInt32(DataBinder.Eval(Container.DataItem,

我对C#很陌生,所以我的问题可能很傻,但我真的不能自己解决它&谷歌。我需要检查年份是否为闰年,因此:

<mso:if runat=server condition='<%# DateTime.IsLeapYear(2000)%>'>

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

错误:

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

但是为什么呢?在一年之前,不要看到任何空间

您使用了两次scriptlet
嵌套,请删除一个

condition='<%# DateTime.IsLeapYear(Convert.ToInt32(DataBinder.Eval(Container.DataItem, "yarr")))%>'
条件=“”

不幸的是,没有,“服务器标签格式不正确”我的答案中缺少一个右括号,请使用更新的代码进行测试。更好的方法是在没有MS SQL的情况下检查年份:int是_leap_year=DateTime。Today.year;。。。
condition='<%# DateTime.IsLeapYear(Convert.ToInt32(DataBinder.Eval(Container.DataItem, "yarr")))%>'