Force multi line field value to output with line breaks?

B

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
 
P

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top