如何在新行中绑定多行文本.. [英] how to bind multiple lines of text in new line..
本文介绍了如何在新行中绑定多行文本..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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...
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
推荐答案
尝试以下代码:-)
try below code :-)
<asp:Literal Text='<%#Limit(Eval("feedback_details"),40)%>' id="Literal1" runat="server"/>
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 />");
}
这篇关于如何在新行中绑定多行文本..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文