Showing posts with label Bind only 25 characters label or text in Gridview control. Show all posts
Showing posts with label Bind only 25 characters label or text in Gridview control. Show all posts

Sunday, 3 February 2013

Bind only 25 characters to the Label Text in Gridview control

First use template field rather than bound filed in Gridview, and bind using

 <ItemTemplate>
  <asp:Label ID="lblName" runat="server" 
Text=' <%# Eval("NAME").ToString().Length > 25 ? Eval("NAME").ToString().Substring(0, 23)+"..": Eval("NAME")%>'>
</asp:Label>
 </ItemTemplate>

Total Pageviews