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. Advertisements

  2. Niclas

    Guest

    Joined:
    Feb 4, 2010
    Messages:
    20
    Likes Received:
    0
    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. Advertisements

  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. Advertisements

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. Jason Coyne  Gaijin42

    Word wrap line break code and algorithm for c#

    Jason Coyne Gaijin42, Apr 8, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    25,048
    Jason Coyne Gaijin42
    Apr 8, 2004
  2. =?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,754
    CraigPaardekooper
    Dec 20, 2011
  3. Hugo
    Replies:
    10
    Views:
    1,605
    Matt Humphrey
    Oct 18, 2004
  4. kaushikshome
    Replies:
    4
    Views:
    1,027
    kaushikshome
    Sep 10, 2006
  5. Replies:
    12
    Views:
    1,351
  6. scad
    Replies:
    23
    Views:
    1,463
    Alf P. Steinbach
    May 17, 2009
  7. hannes

    line break in a datagrid

    hannes, Mar 13, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    209
  8. Marek Stepanek
    Replies:
    12
    Views:
    689
    Peter J. Holzer
    Sep 2, 2006
Loading...