Ramani Sandeep's Blog

DotNetting – Fast , Easy Way of Developing Applications

Archive for October 18th, 2008

How to truncate text in label control

Posted by ramanisandeep on October 18, 2008

C#:

Text=’<%# Eval(“Longtitle”)==DBNull.Value ? “”

:Eval(“Longtitle”).ToString().Substring(0,Math.Min(400,Eval(“Longtitle”).

ToString().Length))+”….” %>’>

A sample for VB.NET(use IIF function):

Text=’<%# IIF(CONVERT.ToString(Eval(“Longtitle”))=”",

“”,Eval(“Longtitle”).ToString().Substring(0,Math.Min(400,Eval(“Longtitle”

).ToString().Length))& “….”) %>’

Posted in ASP.NET 2.0, C# 2.0 | Tagged: , | Leave a Comment »