Solved

Will this Remove characters?

Posted on 2004-09-14
3
284 Views
Last Modified: 2010-04-15
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.
0
Comment
Question by:fallenarmies
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 500 total points
ID: 12055224
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
 

Author Comment

by:fallenarmies
ID: 12055332
should this be inline or in codebehind?
0
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 12055855
fallenarmies ,
Both work for inline or code-behind as well.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question