0

Goal: I have two different columns in a database. Depending on which client it is, I will either want to display the value from one column, or the other in this single (which is inside an ItemTemplate associated to a LayoutTemplate).

Research: I tried looking up similar articles on SO, but they were for slightly different problems, including this one: ASP.Net: Conditional Logic in a ListView's ItemTemplate

Error: I tried using an if statement in the aspx but it tells me I am missing ; even though I have it:

default.aspx:

 <td><%# if(isAAA()) { Item.} else { Item.}; %></td>

I also tried:

  <td><%# if(isAAA()) { Item.; } else { Item.; } %></td>

I also tried:

   <td><% if(isAAA()) { Item.; } else { Item.; } %></td>

I also tried:

       <td><% if(isAAA()) { #Item.; } else { #Item.; } %></td>

I also tried the following, but it placed the value under the wrong column, and it displayed part of the aspx logic on the page:

if(isAAA() { <td><%# Item.%></td> else { <td><%# Item.%></td> }

Note: isAAA() is a method in the .cs file that checks a value in the Settings file.

seesharp
  • 101
  • 1
  • 14

2 Answers2

0

Try this:

<td><%= this.isAAA() ? Item.AAA_Group_ID.ToString() : Item.Group_ID.ToString() %></td>
dev-cc
  • 434
  • 3
  • 13
  • Thanks. It's now saying "The name item does not exist in the current context' . It doesn't say that for any of the other columns where I use Item – seesharp Sep 28 '18 at 13:19
0

I solved it with the following setup:

<% if (is()) %> 
            <% {  %>   
                 <td><%# Item. %></td> 
            <% } %>

            <% else %>
            <% { %>
                  <td><%# Item. %></td>
            <% } %>

This was the closest SO I found : ASP.NET Conditional Markup Rendering According to Web.config Key

seesharp
  • 101
  • 1
  • 14