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.
精彩评论