473,941 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using line breaks in text

We have VS2005 ASP.NET 2.0 application that needs to have each paragraph
separated by a line break. I have added "<br />" into the text column (SQL
2000) and it works fine when displaying on a web page (GridView). However,
when I export the to Excel it creates separate rows for each line break, but
I don't want that. Does anyone have a solution? Thanks.

David
Oct 18 '06 #1
6 5377
You could simply do a replace on the text field to replace the linebreak
with either nothing, or a carriage return. I forget which delimiter Excel
will interpret as the need for a new row so you may have to experiment. You
could do something like .Replace("<br />","") to replace it with nothing
(this is of course used when pulling the data from the database. If you
can't do it at this stage, ie: if you're binding directly to a datareader,
you could have SQL Server do the replacement for you before it gets passed
out to the reader. If I remember correclty, SQL Server does have string
replacement functions.

--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"David" <dl*****@lifeti meinc.comwrote in message
news:Oe******** ******@TK2MSFTN GP04.phx.gbl...
We have VS2005 ASP.NET 2.0 application that needs to have each paragraph
separated by a line break. I have added "<br />" into the text column
(SQL 2000) and it works fine when displaying on a web page (GridView).
However, when I export the to Excel it creates separate rows for each line
break, but I don't want that. Does anyone have a solution? Thanks.

David

Oct 18 '06 #2
Leave the original Line breaks in the database. These are not really part of
the text (data), but part of the UI-specific formatting. Your ASP.Net app
should replace these with "<br />" during execution.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"David" <dl*****@lifeti meinc.comwrote in message
news:Oe******** ******@TK2MSFTN GP04.phx.gbl...
We have VS2005 ASP.NET 2.0 application that needs to have each paragraph
separated by a line break. I have added "<br />" into the text column
(SQL 2000) and it works fine when displaying on a web page (GridView).
However, when I export the to Excel it creates separate rows for each line
break, but I don't want that. Does anyone have a solution? Thanks.

David

Oct 18 '06 #3
You are a genius! I just put code into RowDataBound and did the replacement
when sending to Excel. It seems to work fine and with the "<br />" still in
there, the web pages show what I want. The only downside is that the Excel
field does not have line breaks. Below is my VB code doing the replace.
Does it look ok to you?

strnote = strnote.Replace ("<br />", vbCrLf)

David

"Kevin Spencer" <sp**@uce.govwr ote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
Leave the original Line breaks in the database. These are not really part
of the text (data), but part of the UI-specific formatting. Your ASP.Net
app should replace these with "<br />" during execution.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"David" <dl*****@lifeti meinc.comwrote in message
news:Oe******** ******@TK2MSFTN GP04.phx.gbl...
>We have VS2005 ASP.NET 2.0 application that needs to have each paragraph
separated by a line break. I have added "<br />" into the text column
(SQL 2000) and it works fine when displaying on a web page (GridView).
However, when I export the to Excel it creates separate rows for each
line break, but I don't want that. Does anyone have a solution? Thanks.

David


Oct 18 '06 #4
Looks fine to me, David. Except that I would simply store the native data
(no HTML markup) in the database. This way, the data is not linked in any
way to any user interface, and it is the responsibility of the interface to
do any transforming.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"David" <dl*****@lifeti meinc.comwrote in message
news:uM******** ******@TK2MSFTN GP04.phx.gbl...
You are a genius! I just put code into RowDataBound and did the
replacement when sending to Excel. It seems to work fine and with the
"<br />" still in there, the web pages show what I want. The only
downside is that the Excel field does not have line breaks. Below is my
VB code doing the replace. Does it look ok to you?

strnote = strnote.Replace ("<br />", vbCrLf)

David

"Kevin Spencer" <sp**@uce.govwr ote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
>Leave the original Line breaks in the database. These are not really part
of the text (data), but part of the UI-specific formatting. Your ASP.Net
app should replace these with "<br />" during execution.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"David" <dl*****@lifeti meinc.comwrote in message
news:Oe******* *******@TK2MSFT NGP04.phx.gbl.. .
>>We have VS2005 ASP.NET 2.0 application that needs to have each paragraph
separated by a line break. I have added "<br />" into the text column
(SQL 2000) and it works fine when displaying on a web page (GridView).
However, when I export the to Excel it creates separate rows for each
line break, but I don't want that. Does anyone have a solution? Thanks.

David



Oct 18 '06 #5
Kevin,
Good point. What exactly would you store in the database to represent CrLf?
Thanks.
David
"Kevin Spencer" <sp**@uce.govwr ote in message
news:OC******** ******@TK2MSFTN GP02.phx.gbl...
Looks fine to me, David. Except that I would simply store the native data
(no HTML markup) in the database. This way, the data is not linked in any
way to any user interface, and it is the responsibility of the interface
to do any transforming.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"David" <dl*****@lifeti meinc.comwrote in message
news:uM******** ******@TK2MSFTN GP04.phx.gbl...
>You are a genius! I just put code into RowDataBound and did the
replacement when sending to Excel. It seems to work fine and with the
"<br />" still in there, the web pages show what I want. The only
downside is that the Excel field does not have line breaks. Below is my
VB code doing the replace. Does it look ok to you?

strnote = strnote.Replace ("<br />", vbCrLf)

David

"Kevin Spencer" <sp**@uce.govwr ote in message
news:%2******* *********@TK2MS FTNGP02.phx.gbl ...
>>Leave the original Line breaks in the database. These are not really
part of the text (data), but part of the UI-specific formatting. Your
ASP.Net app should replace these with "<br />" during execution.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"David" <dl*****@lifeti meinc.comwrote in message
news:Oe****** ********@TK2MSF TNGP04.phx.gbl. ..
We have VS2005 ASP.NET 2.0 application that needs to have each
paragraph separated by a line break. I have added "<br />" into the
text column (SQL 2000) and it works fine when displaying on a web page
(GridView) . However, when I export the to Excel it creates separate
rows for each line break, but I don't want that. Does anyone have a
solution? Thanks.

David



Oct 18 '06 #6
As he said earlier

Leave the original Line breaks (CrLf) in the database...

Your ASP.Net app should replace these with "<br />" during execution.

(You must code for this.)
David wrote:
Kevin,
Good point. What exactly would you store in the database to represent CrLf?
Thanks.
David
"Kevin Spencer" <sp**@uce.govwr ote in message
news:OC******** ******@TK2MSFTN GP02.phx.gbl...
Looks fine to me, David. Except that I would simply store the native data
(no HTML markup) in the database. This way, the data is not linked in any
way to any user interface, and it is the responsibility of the interface
to do any transforming.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"David" <dl*****@lifeti meinc.comwrote in message
news:uM******** ******@TK2MSFTN GP04.phx.gbl...
You are a genius! I just put code into RowDataBound and did the
replacement when sending to Excel. It seems to work fine and with the
"<br />" still in there, the web pages show what I want. The only
downside is that the Excel field does not have line breaks. Below is my
VB code doing the replace. Does it look ok to you?

strnote = strnote.Replace ("<br />", vbCrLf)

David

"Kevin Spencer" <sp**@uce.govwr ote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
Leave the original Line breaks in the database. These are not really
part of the text (data), but part of the UI-specific formatting. Your
ASP.Net app should replace these with "<br />" during execution.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"David" <dl*****@lifeti meinc.comwrote in message
news:Oe******* *******@TK2MSFT NGP04.phx.gbl.. .
We have VS2005 ASP.NET 2.0 application that needs to have each
paragraph separated by a line break. I have added "<br />" into the
text column (SQL 2000) and it works fine when displaying on a web page
(GridView). However, when I export the to Excel it creates separate
rows for each line break, but I don't want that. Does anyone have a
solution? Thanks.

David


Oct 19 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2676
by: Bill | last post by:
I am downloading data from a website that displays it in a table $fp = fopen("a website page", 'r'); The following accesses the stream one <td> element at a time $myData = fgets($fp); Then I select the $myData that I want and add them to a string, $str1 while(condition){ $str1 = $str1.$myData; $myData = fgets($fp);
5
2192
by: mailbox | last post by:
Did write it down once, but have forgotten !! How is it you should format your ASP code to that when viewing the resulting HTML text from the browsers "view code" it looks nice with line breaks?
4
22790
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 to export the report? I tried exporting a report by using the .rtf rich-text format (the plain-text format was the only other word-processing option listed when exporting). I then opened the .rtf file in Word. However, it looks like some...
4
1945
by: Alvo von Cossel I | last post by:
hi, i have a button and when it is clicked, a textbox's text will change. the text, however has line breaks in it. here is my code for the button's click event: textBox1.Text = "You clicked the button!\n\n\n\n\nif you exit the application (Alt+F4), you can click the button again!"; the line breaks appear as small squares. how do i display line breaks
2
13212
by: Mike | last post by:
I need my textbox to work more smoothly with respect to line breaks. When I have data pulled from the database into a textbox there are hard line breaks at the end of each line (by definition how Lines property works, right?). But, the textbox is used for editing data previously entered into the database. Ideally, what I want is just a hard break at the end of each paragraph so users can smoothly enter or remove data anywhere without...
1
2685
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 a single line. How can I carry the text as it is entered? Thanks in advance, Burak
1
2108
by: sck10 | last post by:
Hello, I am pulling data from a SQL Server table. One field that is (varchar 4000) is used to show notes. I am using a FormView for showing and editing the data. When the form is in Item view, the text runs together. All the line breaks are missing. When I enter into Edit mode, the text is formatted as it was entered (line breaks). How can I fix this so that when in "Item" mode, the line breaks show?
8
2087
by: Juan Puebla | last post by:
Hi, I have an sql database with some text (nvarchar) fields. The problem is that if I get those fields with a datareader (dr.getstring(0)) an then I save text in a txt file I loose all the line breaks. If I open database Studio Management I see fields like this: Això és una proba pel texte sql. Els canvis de línia no es controlen bé
3
3979
by: Wayne Deleersnyder | last post by:
Hi All, I'm trying to create a function that will cause a pop-up alert to appear if dates which were chosen from a drop-down list were invalid on a page. There's 4 dates, so there's the possibility of 4 errors at once. I'd like to pop-up all the errors at once, so the user can correct all the errors at once. My issue is format. I'd like a message something like... ERROR: Acquired Date Invalid - only 28 days in February for year
0
10134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11530
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11117
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10659
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9860
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6080
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6299
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4487
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.