Search code examples
asp.netsqlevalservercontrols

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 it looks and the EID. How can I accomplish this?

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

Solution

  • 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}") %>