Will this Remove characters?

I just want to know if there is any problems with this code

<%# DataBinder.Eval(Container.DataItem, "diaryEntry").ToString().Substring( 0, DataBinder.Eval(Container.DataItem, "diaryEntry").ToString().Length < 255 ? DataBinder.Eval(Container.DataItem, "diaryEntry").ToString().Length : 255 ) %>

I basically want to limit the post preview to just a few characters.
fallenarmiesAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
David H.H.LeeConnect With a Mentor Commented:
fallenarmies,
Put all this in a function.
eg:
<%#PostData(DataBinder.Eval(Container.DataItem, "diaryEntry"))%>

public string PostData(string strItem)
{
  if(strItem.Length<255)
    return strItem
 else
   return strItem.Substring(0,255)
}
0
 
fallenarmiesAuthor Commented:
should this be inline or in codebehind?
0
 
David H.H.LeeCommented:
fallenarmies ,
Both work for inline or code-behind as well.
0
All Courses

From novice to tech pro — start learning today.