By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,949 Members | 1,511 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,949 IT Pros & Developers. It's quick & easy.

DataGrid Column Heading HTML Encoding ?

P: n/a
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
Feb 27 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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.
Feb 27 '06 #2

P: n/a
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.)

Feb 28 '06 #3

P: n/a
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]" <st*****@online.microsoft.com> wrote in message
news:i$**************@TK2MSFTNGXA03.phx.gbl...
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

Feb 28 '06 #4

P: n/a
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.)

Mar 1 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.