0

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}") %>
atrljoe
  • 8,031
  • 11
  • 67
  • 110

2 Answers2

1

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}") %>
Druid
  • 6,423
  • 4
  • 41
  • 56
  • do you know what exactly these commands are called in aspx pages? Where can I read more about these, I have no idea if I used the correct name, but I would like to find out more about them. Things like the `<%# %> <% %> <%$ %>` – atrljoe Apr 14 '11 at 13:50
  • @atrljoe: The `?:` is called a ternary operator. You can read more [about it here](http://msdn.microsoft.com/en-us/library/ty67wk28%28v=vs.80%29.aspx). More about [C# Operators here](http://msdn.microsoft.com/en-us/library/6a71f45d.aspx). More about [inline ASP.NET tags here](http://naspinski.net/post/inline-aspnet-tags-sorting-them-all-out-%283c25242c-3c253d2c-3c252c-3c252c-etc%29.aspx). – Druid Apr 14 '11 at 14:12
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.

Howard Tucker
  • 438
  • 9
  • 18