Solved

Will this Remove characters?

Posted on 2004-09-14
3
281 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
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

830 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