Displaying line break in Datagrid

Discussion in 'ASP .Net' started by Niclas, Jun 3, 2006.

  1. Niclas

    Niclas Guest

    Hi,

    I have a multiline textbox used to submit values stored as VarChar in my SQL
    database. I need to be able to retrieve this string and display it in a
    datagrid column with the line breaks entered in the textbox maintained.

    Is there a prefered solution available for this ?

    Niclas
    Niclas, Jun 3, 2006
    #1
    1. Advertising

  2. Niclas

    Guest

    Joined:
    Feb 4, 2010
    Messages:
    12
    I would replace all occurences of vbCrLf i.e. character code 10 and 13
    with the <BR/> tag. The datagrid outputs its contents as HTML and in
    HTML whitespace characters such as vbCrLf are ignored. To specify line
    breaks in HTML you have to specify the <BR/> tag in place of vbCrlf.

    you can do this replacement at the point where you select your data
    from the database in your select query. however, i prefer catching the
    DataGrid's ItemDataBound event and fixing the data there - it might be
    less efficient but its better in N-tier applications that I normally
    write.

    hope this helps bro
    Guest, Jun 3, 2006
    #2
    1. Advertising

  3. Niclas

    Niclas Guest

    Works like a charm.

    Many thanks

    Niclas
    <> wrote in message
    news:...
    >I would replace all occurences of vbCrLf i.e. character code 10 and 13
    > with the <BR/> tag. The datagrid outputs its contents as HTML and in
    > HTML whitespace characters such as vbCrLf are ignored. To specify line
    > breaks in HTML you have to specify the <BR/> tag in place of vbCrlf.
    >
    > you can do this replacement at the point where you select your data
    > from the database in your select query. however, i prefer catching the
    > DataGrid's ItemDataBound event and fixing the data there - it might be
    > less efficient but its better in N-tier applications that I normally
    > write.
    >
    > hope this helps bro
    >
    Niclas, Jun 3, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Um9za28=?=

    DataGrid displaying line breaks in bound column

    =?Utf-8?B?Um9za28=?=, Feb 9, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    4,286
    CraigPaardekooper
    Dec 20, 2011
  2. Hugo
    Replies:
    10
    Views:
    1,292
    Matt Humphrey
    Oct 18, 2004
  3. kaushikshome
    Replies:
    4
    Views:
    755
    kaushikshome
    Sep 10, 2006
  4. Replies:
    12
    Views:
    945
  5. hannes

    line break in a datagrid

    hannes, Mar 13, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    132
Loading...

Share This Page