title: Index and length must refer to a location within the string?
body: <p>I am trying to get the first 50  letters, so I used the <code>subString</code> function to get it.</p>
  
  <p>As you can see, I used this code to get it:</p>
  
  <pre><code>&lt;%# Eval("BannerDescription").ToString.Substring(1, 50)%&gt;
  </code></pre>
  
  <p>But unfortunately it's not working and an error message is coming up:</p>
  
  <blockquote>
    <p>Index and length must refer to a location within the string.</p>
  </blockquote>
  
  <p>So is there any other way to fix it?</p>
  
  <p>because the user is the one who is controlling the data entry! some times he gonna enter 10 letters other times maybe 1000 letter so how can i solve this ?</p>
  
  <p>I tried them all but can we use it this way : </p>
  
  <p><code>&lt;%# IIf(Eval("BannerDescription").ToString().Length &gt; 49, Eval("BannerDescription").ToString().Substring(0, 49), Eval("BannerDescription"))%&gt;</code></p>
  
  <p>Thanks.</p>