473,386 Members | 2,129 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,386 software developers and data experts.

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 5342
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*****@lifetimeinc.comwrote in message
news:Oe**************@TK2MSFTNGP04.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*****@lifetimeinc.comwrote in message
news:Oe**************@TK2MSFTNGP04.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.govwrote in message
news:%2****************@TK2MSFTNGP02.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*****@lifetimeinc.comwrote in message
news:Oe**************@TK2MSFTNGP04.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*****@lifetimeinc.comwrote in message
news:uM**************@TK2MSFTNGP04.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.govwrote in message
news:%2****************@TK2MSFTNGP02.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*****@lifetimeinc.comwrote in message
news:Oe**************@TK2MSFTNGP04.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.govwrote in message
news:OC**************@TK2MSFTNGP02.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*****@lifetimeinc.comwrote in message
news:uM**************@TK2MSFTNGP04.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.govwrote in message
news:%2****************@TK2MSFTNGP02.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*****@lifetimeinc.comwrote in message
news:Oe**************@TK2MSFTNGP04.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.govwrote in message
news:OC**************@TK2MSFTNGP02.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*****@lifetimeinc.comwrote in message
news:uM**************@TK2MSFTNGP04.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.govwrote in message
news:%2****************@TK2MSFTNGP02.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*****@lifetimeinc.comwrote in message
news:Oe**************@TK2MSFTNGP04.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
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...
5
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
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...
4
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...
2
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...
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...
1
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...
8
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...
3
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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,...
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
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,...
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...

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.