Home All Groups Group Topic Archive Search About

Force multi line field value to output with line breaks?

Author
22 Jan 2006 4:48 PM
bernadou
I have a field value that might look like this in the db
First Line
Second Line
Third Line

When I query the data and output that data to a label in my gridveiw it
looks like this:
First Line Second Line Third Line

How to I insert HTML formatting into the label text so it will render in the
same fashion it was entered in the db?

Or in other words, render with "<BR>" tags in place of the line breaks in
the data?

Thanks!
B

Author
22 Jan 2006 8:50 PM
Phillip Williams
Hello again Bernie,

You can use Environment.NewLine with the Replace method like this:

<asp:label runat="Server" ID="lblNotes" Text='<%#
Eval("fldNodes").ToString().Replace(Environment.NewLine, "<br>")
%>'></asp:label>
Show quoteHide quote
"bernadou" wrote:

> I have a field value that might look like this in the db
> First Line
> Second Line
> Third Line
>
> When I query the data and output that data to a label in my gridveiw it
> looks like this:
> First Line Second Line Third Line
>
> How to I insert HTML formatting into the label text so it will render in the
> same fashion it was entered in the db?
>
> Or in other words, render with "<BR>" tags in place of the line breaks in
> the data?
>
> Thanks!
> B
Author
23 Jan 2006 1:23 PM
bernadou
Phillip,
Once again you nailed it.  I"ll give this a shot.  Much appreciated.

Show quoteHide quote
"Phillip Williams" wrote:

> Hello again Bernie,
>
> You can use Environment.NewLine with the Replace method like this:
>
> <asp:label runat="Server" ID="lblNotes" Text='<%#
> Eval("fldNodes").ToString().Replace(Environment.NewLine, "<br>")
> %>'></asp:label>
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "bernadou" wrote:
>
> > I have a field value that might look like this in the db
> > First Line
> > Second Line
> > Third Line
> >
> > When I query the data and output that data to a label in my gridveiw it
> > looks like this:
> > First Line Second Line Third Line
> >
> > How to I insert HTML formatting into the label text so it will render in the
> > same fashion it was entered in the db?
> >
> > Or in other words, render with "<BR>" tags in place of the line breaks in
> > the data?
> >
> > Thanks!
> > B