Link to home
Start Free TrialLog in
Avatar of dageyra
dageyraFlag for United States of America

asked on

Replacing new line with HTML break from SQL data

I am pulling some data from a table where a column has its data delimitted via new line, \n.  This data is going to be presented to the page, so the \n needs to be converted to <br />.  I am using SQL's replace function to handle this conversion, which works fine.  The data is bound to a DetailsView, which is where things go wrong.  Instead of seeing the data all lined up nicely, the <br /> is turned into &lt;BR/&gt;, basically the HTML encoding equivalent of <br />.  I know that when I get the data from SQL Server, it is not encoded, so I presume the DetailsView is causing the problem.

How can I get around this issue with the DetailsView or is there an alternative method I could try?
I Do Not Smoke&lt;BR/&gt;
My Roommate Should Not Smoke&lt;BR/&gt;
I Have Pets&lt;BR/&gt;
I Have Pets In My Home&lt;BR/&gt;
I Prefer A City Location&lt;BR/&gt;
I Need At Least7 Or8 Hours Of Sleep&lt;BR/&gt;
 
I Prefer Loud Music&lt;BR/&gt;

Open in new window

Avatar of spprivate
spprivate
Flag of United States of America image

ASKER CERTIFIED SOLUTION
Avatar of spprivate
spprivate
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dageyra

ASKER

I modified your suggestion slightly (I did not need the BoundField at all), but worked like a charm.  Thanks for the help.
Avatar of dageyra

ASKER

Perfect