title: Change img src in asp.net
body: <p>So I have a bool column in my database that says if visitor is "Inhouse" or not. If the value is <code>true</code> I want the img src to be: <code>const string checkedIn = "/Images/Icons/Visitor-checkedin-16x16.png";</code> if <code>false</code>, I want it to be another src. And also, if visitor has not visited yet, "Inhouse" should be <code>false</code> AND the "expectedArrival" date has not been yet. Here is my code:</p>
  
  <p><strong>C#:</strong></p>
  
  <pre class="lang-cs prettyprint-override"><code>public string GetImageUrl(string inhouse, DateTime expectedArrival)
  {
      const string checkedIn = "/Images/Icons/Visitor-checkedin-16x16.png";
      const string checkedOut = "/Images/Icons/Visitor-checkedout-16x16.png";
      const string notArrived = "/Images/Icons/Visitor-notarrived-16x16.png";
  
      if (ToBool(inhouse))
      {
          inhouse = checkedIn;
      }
  
      else if (ToBool(inhouse) == false &amp;&amp; expectedArrival.AddDays(0) &lt;= DateTime.Now)
      {
          inhouse = notArrived;
      }
  
      else
      {
          inhouse = checkedOut;
      }
  
      return inhouse;
  }
  
  private static bool ToBool(string value, bool defaultValue = false)
  {
      bool result;
      return bool.TryParse(value, out result)
          ? result
          : defaultValue;
  }
  </code></pre>
  
  <p><strong>ASPX:</strong></p>
  
  <pre><code>&lt;asp:Repeater runat="server" OnItemDataBound="rptVisitedItem_OnItemDataBound" OnItemCommand="rptVisitedItem_OnItemCommand" ID="rptVisitedItem"&gt;
       &lt;ItemTemplate&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;img src='&lt;%# GetImageUrl(Eval("Inhouse").ToString(), Convert.ToDateTime(Eval("ExpectedArrival"))) %&gt;'alt="" class="statusIcon" /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/ItemTemplate&gt;
  &lt;/asp:Repeater&gt;
  </code></pre>
  
  <p>Where have I done wrong? I only get one image to show atm.</p>