Click here to Skip to main content
15,895,777 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
XML
I need to bind multiple lines of text from backend in repeater..
i have used this..
Text='<%#Limit(Eval("feedback_details"),40)%>'


I have used like this...

C#
protected string Limit(object Desc, int length)
    {
    StringBuilder strDesc = new StringBuilder();
    strDesc.Insert(0, Desc.ToString());

    if (strDesc.Length > length)
    {
        return strDesc.ToString().Substring(0, length) + "...";
    }
    else return strDesc.ToString();
    }


it displays the text in same line like this
this is a sample.......



I need to show the text in new line..

kindly help me..

thanks in advance
Posted

1 solution

try below code :-)
ASP.NET
<asp:Literal Text='<%#Limit(Eval("feedback_details"),40)%>' id="Literal1" runat="server"/>

C#
protected string Limit(object Desc, int length)
{
    StringBuilder strDesc = new StringBuilder();
    strDesc.Insert(0, Desc.ToString());
    string result ="";
    if (strDesc.Length > length)
    {
        result = strDesc.ToString().Substring(0, length) + "...";
    }
    else result =strDesc.ToString();
    return result.Replace(Environment.NewLine, "<br />");
}
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900