Using line breaks in text

Discussion in 'ASP .Net' started by David, Oct 18, 2006.

  1. David

    David Guest

    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
    David, Oct 18, 2006
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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
    >
    Mark Fitzpatrick, Oct 18, 2006
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:...
    > 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
    >
    Kevin Spencer, Oct 18, 2006
    #3
  4. David

    David Guest

    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" <> wrote in message
    news:%...
    > 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" <> wrote in message
    > news:...
    >> 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
    >>

    >
    >
    David, Oct 18, 2006
    #4
  5. 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" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:%...
    >> 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" <> wrote in message
    >> news:...
    >>> 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
    >>>

    >>
    >>

    >
    >
    Kevin Spencer, Oct 18, 2006
    #5
  6. David

    David Guest

    Kevin,
    Good point. What exactly would you store in the database to represent CrLf?
    Thanks.
    David
    "Kevin Spencer" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:...
    >> 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" <> wrote in message
    >> news:%...
    >>> 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" <> wrote in message
    >>> news:...
    >>>> 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
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
    David, Oct 18, 2006
    #6
  7. David

    Russell Guest

    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" <> wrote in message
    > news:...
    > > 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" <> wrote in message
    > > news:...
    > >> 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" <> wrote in message
    > >> news:%...
    > >>> 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" <> wrote in message
    > >>> news:...
    > >>>> 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
    > >>>>
    > >>>
    > >>>
    > >>
    > >>

    > >
    > >
    Russell, Oct 19, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lloyd Sheen

    Render text with line breaks

    Lloyd Sheen, Sep 22, 2004, in forum: ASP .Net
    Replies:
    7
    Views:
    641
    =?Utf-8?B?SmVyZW15IERhdmlz?=
    Sep 22, 2004
  2. Herbert Gerstinger

    Text with automated line-breaks for a picture

    Herbert Gerstinger, Aug 7, 2005, in forum: HTML
    Replies:
    26
    Views:
    789
    Toby Inkster
    Aug 9, 2005
  3. David Blickstein

    Line breaks in text mode for XSLT

    David Blickstein, Jun 28, 2005, in forum: XML
    Replies:
    5
    Views:
    2,149
    Peter Flynn
    Jul 3, 2005
  4. bernadou

    Force multi line field value to output with line breaks?

    bernadou, Jan 22, 2006, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    358
    bernadou
    Jan 23, 2006
  5. Marek Stepanek
    Replies:
    12
    Views:
    412
    Peter J. Holzer
    Sep 2, 2006
Loading...

Share This Page