EVAL检查的DBNull不工作 [英] Eval check for DBNull doesnt work
本文介绍了EVAL检查的DBNull不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<%# Eval("Description") == DBNull.Value ? "empty" : "notempty"%>
总是显示出一个'NotEmpty'甚至有在DB那场空(VARCHAR(类型),空)
...
尝试也检查空字符串:
is showing always 'notempty' even there is null in that field in DB (type of varchar(), null) ... Tried also checking for empty string:
<%# Eval("Description") == "" ? "empty" : "notempty"%>
和它总是显示notempty ...什么是错在这里?
and it always displays notempty... what's wrong here??
推荐答案
有 DBNull.Value
和空$ C之间的差异$ C>。这是可能的领域正在恢复
空
。
There is a difference between DBNull.Value
and null
. It is possible the field is returning null
.
尝试
<%# Eval("Description") == null ? "empty" : "notempty"%>
此外,如果字段值类型应该是字符串,你可以沿着线做一些事情。
Also if the field value type is supposed to be string you could do something along the lines of..
<%# (Eval("Description") as string) ?? "empty" %>
这篇关于EVAL检查的DBNull不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文