title: c# Remove parts of string from label inside an datalist
body: <p>Im working on a small news applicaton and im trying to remove parts of a text from a label inside a datalist, here is my code</p>
  
  <pre><code>&lt;asp:DataListID="itemListNews"runat="server"&gt;
         &lt;ItemTemplate&gt;      
              &lt;div class="news"&gt;
                  &lt;span class="news-author"&gt;&lt;%#DataBinder.Eval(Container.DataItem,"author") %&gt;&lt;/span&gt;
                  &lt;asp:Label ID="lbTest" runat="server" class="news-text"&gt;&lt;%#DataBinder.Eval(Container.DataItem,"news") %&gt;&lt;/asp:Label&gt;
              &lt;/div&gt;   
         &lt;/ItemTemplate&gt;
  </code></pre>
  
  <p>I have been trying a couple of things and i keep getting the error message: <code>startIndex must be less than the length of the string.Parameter name: startIndex</code></p>
  
  <pre><code>foreach (DataListItem item in itemListNews.Items)
      {
          Label lbtest = (Label) item.FindControl("lbTest");
          lbtest.Text.Remove(10);    
      }
  </code></pre>
  
  <p>Any suggestions would be helpful</p>