Maintaining line breaks from MySQL text field to datagrid

Posted on 2009-02-24
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?

Question by:j-w-thomas
    LVL 4

    Accepted Solution


    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?
    LVL 3

    Author Comment

    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
    LVL 3

    Author Comment

    Thanks for trying, I will award partial points...
    LVL 4

    Expert Comment

    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 ;-)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
    Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now