By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,369 Members | 1,131 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,369 IT Pros & Developers. It's quick & easy.

Formview Line Breaks

P: n/a
MDB
Hello All, I have a label in a form view that I need to have display the
line breaks. Is there an easy way to do this? For some reason, I havn't
been able to find a straigh answer on this.

Here is what I have:

<asp:FormView ID="FormView1" runat="server" DataKeyNames="ID"
DataSourceID="SqlDataSource2" Width="565px">
<itemtemplate>
<table width="565" style="table-layout: fixed;word-break:break-all" >
<tr>
<td style="color: white; background-color: #d40000; text-align:
center">
&nbsp;<b><asp:Label ID="titleLabel" runat="server" Text='<%#
Bind("title") %>'></asp:Label></b>
</td>
</tr>
<tr>
<td align="left" style="background-color: #e0e0e0">
&nbsp;<asp:Label ID="blogentryLabel" runat="server"
Text='<%# Server.HtmlEncode(Eval("blogentry").ToString())
%>'></asp:Label></td>
</tr>

</table>
</itemtemplate>
</asp:FormView>
It displays the text like this (one continuous line):
as fsdajfkl jdjsdkfa jdsklfj;a fjf asdkf;lj kl;fajdf; dkjf daf;lsaf
fsakffas' fafds;f kdjf fafds;f kdjf ds;f kdjf fafds;f kdjf sajhf dsafkaj
fdfkashf oidsahfda fhadsifjep89fa jfsafdajf 9o8afsafkasca ewauifa oiduaf
aifuosad oiaufp ndsaopi ufwaoiauf snkzpoweqiurf ajsdopfueqw

If I view this source it is displayed correctly with the line breaks:

sjadfjl akjf

aksj fsakf

asd hfsadf asdf lkwajf oaiu asjkldsj oiqua

I am sorry for asking a question that appears to have been asked multiple
time however, I still can not seem to get it figured out.

Thanks In Advance
Aug 24 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Create a CSS style for your label. It should contain:

white-space: pre;

that'll do it!!

"MDB" wrote:
Hello All, I have a label in a form view that I need to have display the
line breaks. Is there an easy way to do this? For some reason, I havn't
been able to find a straigh answer on this.

Here is what I have:

<asp:FormView ID="FormView1" runat="server" DataKeyNames="ID"
DataSourceID="SqlDataSource2" Width="565px">
<itemtemplate>
<table width="565" style="table-layout: fixed;word-break:break-all" >
<tr>
<td style="color: white; background-color: #d40000; text-align:
center">
<b><asp:Label ID="titleLabel" runat="server" Text='<%#
Bind("title") %>'></asp:Label></b>
</td>
</tr>
<tr>
<td align="left" style="background-color: #e0e0e0">
<asp:Label ID="blogentryLabel" runat="server"
Text='<%# Server.HtmlEncode(Eval("blogentry").ToString())
%>'></asp:Label></td>
</tr>

</table>
</itemtemplate>
</asp:FormView>
It displays the text like this (one continuous line):
as fsdajfkl jdjsdkfa jdsklfj;a fjf asdkf;lj kl;fajdf; dkjf daf;lsaf
fsakffas' fafds;f kdjf fafds;f kdjf ds;f kdjf fafds;f kdjf sajhf dsafkaj
fdfkashf oidsahfda fhadsifjep89fa jfsafdajf 9o8afsafkasca ewauifa oiduaf
aifuosad oiaufp ndsaopi ufwaoiauf snkzpoweqiurf ajsdopfueqw

If I view this source it is displayed correctly with the line breaks:

sjadfjl akjf

aksj fsakf

asd hfsadf asdf lkwajf oaiu asjkldsj oiqua

I am sorry for asking a question that appears to have been asked multiple
time however, I still can not seem to get it figured out.

Thanks In Advance
Aug 24 '06 #2

P: n/a
MDB
That worked great, now I have a new question, how do I get to to word wrap?
I ahve the width set to 565 but the lines never break.
"David Jessee" <Da*********@discussions.microsoft.comwrote in message
news:B2**********************************@microsof t.com...
Create a CSS style for your label. It should contain:

white-space: pre;

that'll do it!!

"MDB" wrote:
>Hello All, I have a label in a form view that I need to have display the
line breaks. Is there an easy way to do this? For some reason, I havn't
been able to find a straigh answer on this.

Here is what I have:

<asp:FormView ID="FormView1" runat="server" DataKeyNames="ID"
DataSourceID="SqlDataSource2" Width="565px">
<itemtemplate>
<table width="565" style="table-layout: fixed;word-break:break-all"
> >
<tr>
<td style="color: white; background-color: #d40000;
text-align:
center">
<b><asp:Label ID="titleLabel" runat="server" Text='<%#
Bind("title") %>'></asp:Label></b>
</td>
</tr>
<tr>
<td align="left" style="background-color: #e0e0e0">
<asp:Label ID="blogentryLabel" runat="server"
Text='<%# Server.HtmlEncode(Eval("blogentry").ToString())
%>'></asp:Label></td>
</tr>

</table>
</itemtemplate>
</asp:FormView>
It displays the text like this (one continuous line):
as fsdajfkl jdjsdkfa jdsklfj;a fjf asdkf;lj kl;fajdf; dkjf daf;lsaf
fsakffas' fafds;f kdjf fafds;f kdjf ds;f kdjf fafds;f kdjf sajhf dsafkaj
fdfkashf oidsahfda fhadsifjep89fa jfsafdajf 9o8afsafkasca ewauifa oiduaf
aifuosad oiaufp ndsaopi ufwaoiauf snkzpoweqiurf ajsdopfueqw

If I view this source it is displayed correctly with the line breaks:

sjadfjl akjf

aksj fsakf

asd hfsadf asdf lkwajf oaiu asjkldsj oiqua

I am sorry for asking a question that appears to have been asked multiple
time however, I still can not seem to get it figured out.

Thanks In Advance

Aug 24 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.