DataGrid Column Heading HTML Encoding ?

A

Adrian Parker

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 ?
 
E

Erik Funkenbusch

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

Steven Cheng[MSFT]

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.)
 
A

Adrian Parker

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

Steven Cheng[MSFT]

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top