DataGrid Column Heading HTML Encoding ?

Discussion in 'ASP .Net' started by Adrian Parker, Feb 27, 2006.

  1. Can someone tell me how to be able to force line breaks in a datagrid column
    heading? If the text contains "abc<br>def" then that is what comes out;
    the source view contains the "abc&lt;br&gt;def". I'll assume that this
    isn't just a problem with datagrid column headings, so is there a generic
    solution ?
    --
    Adrian Parker
    Ingenuity At Work Ltd
    Adrian Parker, Feb 27, 2006
    #1
    1. Advertising

  2. On Mon, 27 Feb 2006 13:09:20 -0000, Adrian Parker wrote:

    > Can someone tell me how to be able to force line breaks in a datagrid column
    > heading? If the text contains "abc<br>def" then that is what comes out;
    > the source view contains the "abc&lt;br&gt;def". I'll assume that this
    > isn't just a problem with datagrid column headings, so is there a generic
    > solution ?


    The easiest solution is to just go into your aspx page in code view and
    change the header text. remember to add the closing /> to make it xhtml
    compliant.
    Erik Funkenbusch, Feb 27, 2006
    #2
    1. Advertising

  3. Hi Adrian,

    Are you using ASP.NET 1.1 or ASP.NET 2.0. I've just tried using the
    DataGrid in ASP.NET 2.0 page with some html element like <br/> in the
    BoundColumn's HeaderText and it can works. Also, I think you can consider
    using TemplateColumn since it can let us customize the Header by inputing
    discretionary html content in the HeaderTemplate.

    Hope this helps.

    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    Steven Cheng[MSFT], Feb 28, 2006
    #3
  4. Hi Steven,

    Just found the solution.. We're using 2.0 and we were already using a
    templare which inherits from BoundField.

    What we needed to do was to add the following to the template properties:-

    Protected Overrides ReadOnly Property SupportsHtmlEncode() As Boolean
    Get
    Return False
    End Get
    End Property

    Then the html is rendered as expected.

    --
    Adrian Parker
    Ingenuity At Work Ltd

    "Steven Cheng[MSFT]" <> wrote in message
    news:i$...
    > Hi Adrian,
    >
    > Are you using ASP.NET 1.1 or ASP.NET 2.0. I've just tried using the
    > DataGrid in ASP.NET 2.0 page with some html element like <br/> in the
    > BoundColumn's HeaderText and it can works. Also, I think you can consider
    > using TemplateColumn since it can let us customize the Header by inputing
    > discretionary html content in the HeaderTemplate.
    >
    > Hope this helps.
    >
    > Regards,
    >
    > Steven Cheng
    > Microsoft Online Support
    Adrian Parker, Feb 28, 2006
    #4
  5. That's cool Adrian,

    Thanks for your followup and share the solution with us.

    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    Steven Cheng[MSFT], Mar 1, 2006
    #5
    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. dm1608
    Replies:
    1
    Views:
    1,611
    Eliyahu Goldin
    Feb 19, 2006
  2. mark4asp
    Replies:
    2
    Views:
    619
    Jasbird
    Nov 11, 2006
  3. JB
    Replies:
    1
    Views:
    386
    Alexey Smirnov
    Oct 21, 2009
  4. JB
    Replies:
    3
    Views:
    1,992
    Alexey Smirnov
    Oct 21, 2009
  5. Alan Z. Scharf

    Underline Hyperlink Column Heading Only

    Alan Z. Scharf, Dec 7, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    201
    Alan Z. Scharf
    Dec 17, 2004
Loading...

Share This Page