473,395 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

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
2 9671
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: chokky | last post by:
I'm using the mail($MailTo, $Subject, $Body, $headers) function to send out plain text emails, with the message/body being entered via a form. When the email arrives, the message is displayed as a...
4
by: intl04 | last post by:
I have a memo field that is included in some Access reports I created. Is there some way for the memo field to display nicely formatted text, with line breaks between paragraphs? Or is it necessary...
1
by: buran | last post by:
Dear ASP.NET Programmers, I am carrying the input of a textbox via querystring. When I put the value of querstring in a label control, the line breaks are removed. The whole text is displayed as...
7
by: mattrapoport | last post by:
I have a page with a div on it. The div displays a user comment. When the user logs into this page, their current comment is pulled from a db and displayed in the div. The user can edit the...
4
by: e34m5 | last post by:
I imported data from Excel into Access. In the Excel cells the text has been formatted with carriage returns. Access does not recognize them as such and the text looks like this: ZJP-2024-100-A1 □...
0
by: alexpetrie | last post by:
I am using a form to enter data and I want to be able to add line breaks within a single field <shift><enter> or <control><enter> puts them into the form field and they seem to be stored in the...
1
by: jollyroger | last post by:
I have searched the web forums, and can't seem to find an answer to this particular problem I have. In an excel sheet, cells in one column have formatted text in the "wrapped" cells. For many of...
0
by: lundmark | last post by:
When I send a plain-text message using Outook 2007, I want hard line breaks to be added to my outgoing message. I cannot seem to make this happen. I have configured Outlook to Automatically wrap...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.