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>

No comments:

Post a Comment

Total Pageviews