title: If check on DataBound Control?
body: <p>How do you correctly check a <code>concatenated string</code> for length in asp.net?</p>
  
  <p>If the total length of <code>Eval("FirstName")</code> and <code>Eval("LastName")</code>is longer than 21 I want to shorten the string and add "..." to the end.</p>
  
  <pre><code>&lt;span id="userNameText"&gt;
          &lt;%if (string.Concat(Eval("FirstName"), " ", Eval("LastName")).ToString().Length &gt; 21)
            {
                string.Concat(Eval("FirstName"), " ", Eval("LastName")).ToString().PadRight(19).Substring(0, 19).TrimEnd() + "...";
            }
            else
            {
                string.Concat(Eval("FirstName"), " ", Eval("LastName"));
            }
          %&gt;
      &lt;/span&gt;
  </code></pre>