在DataList中怎样对文本进行分段?

来源:百度知道 编辑:UC知道 时间:2024/05/14 11:08:48
在DataList中怎样对文本进行分段?

我使用的的是VS2005,

在DataList的<ItemTemplate>中显示文章,(用Label来接受数据再导入到SQL数据库中然后显示)但是不能分段,全部堆在一起.
<asp:Label ID="Label4" runat="server" Font-Size="10pt" Text='<%# Eval("context") %>'></asp:Label>

我试过在<ItemTemplate>中加入<pre>:

<ItemTemplate>
<pre><%# (DataBinder.Eval(Container.DataItem,"text").ToString()) %></pre>

可是运行后出错了,说:"DataBinding:“System.Data.Common.DbDataRecord”不包含名为“text”的属性。"

请问有什么办法可以解决分段问题吗?
问题已经解决了.<pre><%# (DataBinder.Eval(Container.DataItem,"text").ToString().replace("\n","<BR>")) %></pre>.还是谢谢大家!

text?context?

真是受不了...
<pre><%# (DataBinder.Eval(Container.DataItem,"text").ToString()) %></pre>
这段东西你一定是考来的..怎么也不改一改..你数据源里有text这个字段吗

-----
用CSS实现吧,最简单
WORD-BREAK: break-all; WORD-WRAP: break-word;

不要用pre不分段 是你存的时候的问题
保存:string content = textbox1.Text.Replace("\n","<br>").Replace(" "," ");