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

Keeping text control characters (line breaks / carriage returns) in DetailsView field

P: n/a
I have a bound field in a DetailsView control that displays free form
description type data from my SQL database table (typical data is a
couple of paragraphs of written product description being held in a
single database field of type ntext).

This description data typically has various simple control characters
in it - ie. new line, carriage returns etc) to make the paragraph more
readable.

My problem is that these control characters are lost / don't work....
When I run the application all text in the field displays as a simple
lump of text.. without any new lines etc.

Below is the simple definition I am using inside the DetailsView..

<asp:BoundField DataField="Description" HeaderText="Description"
SortExpression="Description" />

Can anyone suggest a solution ?

Thanks,
Bazza

Aug 1 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Aug 1, 10:57 pm, Bazza Formez <bruce_for...@clear.net.nzwrote:
I have a bound field in a DetailsView control that displays free form
description type data from my SQL database table (typical data is a
couple of paragraphs of written product description being held in a
single database field of type ntext).

This description data typically has various simple control characters
in it - ie. new line, carriage returns etc) to make the paragraph more
readable.

My problem is that these control characters are lost / don't work....
When I run the application all text in the field displays as a simple
lump of text.. without any new lines etc.

Below is the simple definition I am using inside the DetailsView..

<asp:BoundField DataField="Description" HeaderText="Description"
SortExpression="Description" />
instead of BoundField use a TemplateField

<asp:TemplateField>
<ItemTemplate>
<%# Replace(Container.DataItem("Description"), vbCrLf, "<br>") %>
</ItemTemplate>
</asp:TemplateField>

and in C# use

Replace("\n", "<br>");

Aug 1 '07 #2

P: n/a
On Aug 2, 9:24 am, Alexey Smirnov <alexey.smir...@gmail.comwrote:
On Aug 1, 10:57 pm,BazzaFormez<bruce_for...@clear.net.nzwrote:


I have a bound field in a DetailsView control that displays free form
description type data from my SQL database table (typical data is a
couple of paragraphs of written product description being held in a
single database field of type ntext).
This description data typically has various simple control characters
in it - ie. new line, carriage returns etc) to make the paragraph more
readable.
My problem is that these control characters are lost / don't work....
When I run the application all text in the field displays as a simple
lump of text.. without any new lines etc.
Below is the simple definition I am using inside the DetailsView..
<asp:BoundField DataField="Description" HeaderText="Description"
SortExpression="Description" />

instead of BoundField use a TemplateField

<asp:TemplateField>
<ItemTemplate>
<%# Replace(Container.DataItem("Description"), vbCrLf, "<br>") %>
</ItemTemplate>
</asp:TemplateField>

and in C# use

Replace("\n", "<br>");- Hide quoted text -

- Show quoted text -
Thank you very much Alexey!

Aug 6 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.