开发者

ASP Server Controls If SQL Field is Populated

I am trying to figure out how I can use ASP Server Control tags to determine if the field I am evaluating is return anything if not then it needs to check another field that has data in it. I have the two statements below, and I was wondering How can I combine them so that if the CID doesn't exist then i开发者_运维问答t looks and the EID. How can I accomplish this?

<%# Eval("CID", "us.aspx?id={0}") %>
<%# Eval("EID", "ei.aspx?id={0}") %>


Do you mean if Eval("CID") is null, then show EID or show the CID? You could try:

<%# (Eval("CID") == null) ? Eval("EID", "ei.aspx?id={0}") : Eval("CID", "us.aspx?id={0}") %>


In VB you can accomplish this by using the following

<%# IIF(IsDBNULL("CID"), "ei.aspx?id={" & Eval("EID") & "}", "us.aspx?id={" & Eval("CID") & "}") 

You may want to use IsNothing in place of IsDBNull depending on your situation.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜