title: Conditional Logic in ASP.net page
body: <p>I have some code that prints out databse values into a repeater control on an asp.net page.  However, some of the values returned are null/blank - and this makes the result look ugly when there are blank spaces.  </p>
  
  <p>How do you do conditional logic in asp.net controls i.e. print out a value if one exists, else just go to next value.</p>
  
  <p>I should also add - that I want the markup to be conditional also, as if there is no value I dont want a <br> tag either.</p>
  
  <p>Here is a snippet of code below just to show the type of values I am getting back from my database.  (It is common for <strong>Address 2</strong> not to have a value at all).</p>
  
  <pre><code>&lt;div id="results"&gt;
      &lt;asp:Repeater ID="repeaterResults" runat="server"&gt;
          &lt;ItemTemplate&gt;
               Company:      &lt;strong&gt;&lt;%#Eval("CompanyName") %&gt;&lt;/strong&gt;&lt;br /&gt;
               Contact Name: &lt;strong&gt;&lt;%#Eval("ContactName") %&gt;&lt;/strong&gt;&lt;br /&gt;
               Address:      &lt;strong&gt;&lt;%#Eval("Address1")%&gt;&lt;/strong&gt;&lt;br /&gt;                    
                             &lt;strong&gt;&lt;%#Eval("Address2")%&gt;&lt;/strong&gt;&lt;br /&gt;..................
  </code></pre>
  
  <p>Many thanks</p>