?
Solved

Maintaining line breaks from MySQL text field to datagrid

Posted on 2009-02-24
4
Medium Priority
?
633 Views
Last Modified: 2012-05-06
I have a TEXT formatted field in a MySQL db and I want to maintain the line breaks on the select statement when I review the data.

Can I use DataStringFormat in a bound column to replace the breaks with "<br />" or can I use the Replace() in the SQL statement?

Thanks
0
Comment
Question by:j-w-thomas
  • 2
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
davidsperling earned 1500 total points
ID: 23721880
http://www.webmasterworld.com/forum47/2246.htm

Don't know if it'll work with C# (it's vb)

Anyway, the principle is to replace all occurences of CrLf with "<br />".

Should be some constant for CrLf in C# too, right?
0
 
LVL 3

Author Comment

by:j-w-thomas
ID: 23722285
Yes, I understand that part, but I was wondering if I can do this as I am pulling the data from the db or can I create a format within the datagrid itself in a bound column.

The line for a bound column for date format is:

<asp:BoundColumn DataField="NOTES" HeaderText="Notes" DataFormatString="{0:d}" />

Can I use a "replace" function within the bound column
0
 
LVL 3

Author Comment

by:j-w-thomas
ID: 23725808
Thanks for trying, I will award partial points...
0
 
LVL 4

Expert Comment

by:davidsperling
ID: 23731390
There must be a Replace function in MSSQL too. Create a View that selecs Replace(MyField,CrLf,"</br>") rather than MyField.
And bind it to you "bound column".

Thanks for reminding me that the grass isn't always greener on the other side!
(I've been a bit depressed that I choose the php path ;-)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month14 days, 15 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question