dageyra
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 <BR/>, 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?
How can I get around this issue with the DetailsView or is there an alternative method I could try?
I Do Not Smoke<BR/>
My Roommate Should Not Smoke<BR/>
I Have Pets<BR/>
I Have Pets In My Home<BR/>
I Prefer A City Location<BR/>
I Need At Least7 Or8 Hours Of Sleep<BR/>
I Prefer Loud Music<BR/>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I modified your suggestion slightly (I did not need the BoundField at all), but worked like a charm. Thanks for the help.
ASKER
Perfect
http://objectmix.com/dotnet/96427-keeping-text-control-characters-line-breaks-carriage-returns-detailsview-field.html