Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Will this Remove characters?

Posted on 2004-09-14
3
Medium Priority
?
286 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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

722 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