How to use a ASP.NET Eval() function in a ternary operator?

后端 未结 2 1071
南笙
南笙 2021-01-22 03:41

I am looking to evaluate two strings from my dataset to identify a class description using a ternary operator. I continue to get a compiler error when running this code stating

2条回答
  •  情书的邮戳
    2021-01-22 04:28

    I think the problem is that you are trying to do comparison between two strings. Just convert the values to a int or something similar for comparison. So for example, change your comparison to something like the below:

     Convert.ToInt32(Eval("Team2Score"))) ? 'Winner':'' %>"><%# Eval("Team1")%>
    

    Or you can just cast it to the appropriate type:

     (int)Eval("Team2Score")) ? 'Winner':'' %>"><%# Eval("Team1")%>
    

    Hope this helps!

提交回复
热议问题