开发者

Web forms, if eval() is 0

开发者 https://www.devze.com 2023-02-09 03:58 出处:网络
I have a problem in a Web Forms project. I have a gridview bound to a SqlDataSource. In my gridview\'s ItemTemplate I have following code:

I have a problem in a Web Forms project. I have a gridview bound to a SqlDataSource.

In my gridview's ItemTemplate I have following code:

<li><asp:Literal id='eingangLiteral' runat='server' Text='<%# (int)Eval("countCallsEingang") == 0 ? "" : Eval("countCallsEingang") + " eingegangen   "%>'></asp:Literal></li>

The problem with this is, that my li html tag also is shown when Eval("countsCallEingang") is 0 and displaye开发者_JAVA百科d as empty.

So I have to make the 0 check before the li tag and show the li tag only when it is not 0. How do I form a If-Clause or something similar in this case?


Firstly, do you need the literal value? If not, then you could do

<%# (int)Eval("countCallsEingang") == 0 ? "" : "<li>" + Eval("countCallsEingang") + " eingegangen   " + "</li>" %>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号