Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bazza Formez - 01 Aug 2007 21:57 GMT
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
Alexey Smirnov - 01 Aug 2007 22:24 GMT
> 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
[quoted text clipped - 13 lines]
> <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>");
Bazza Formez - 06 Aug 2007 21:53 GMT
> On Aug 1, 10:57 pm,BazzaFormez<bruce_for...@clear.net.nz> wrote:
>
[quoted text clipped - 29 lines]
>
> - Show quoted text -

Thank you very much Alexey!

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.