Add the ... after string lengh
{
if (String.IsNullOrEmpty(s))
throw new ArgumentNullException(s);
var words = s.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (words[0].Length > length)
return words[0];
var sb = new StringBuilder();
foreach (var word in words)
{
if ((sb + word).Length > length)
return string.Format("{0}...", sb.ToString().TrimEnd(' '));
sb.Append(word + " ");
}
return string.Format("{0}...", sb.ToString().TrimEnd(' '));
}
Call the method:-
lblTechnologyUsed.Text = strStringTruncates((e.Row.DataItem as DataRowView).Row["Technology_x0020_Used"].ToString().Trim(), 50);
No comments:
Post a Comment