473,396 Members | 2,018 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

GridView header column text getting html encoded

TS
I have a headerText for a header column that is "Page<br>Name". it puts a
<brto force a line break, but the < and get encoded to &lt; and &gt;
thus negating its effect as an html control and doesn't respect the line
break

I'm guessing this happens during render. What do i need to do to keep the
line break?
Jul 4 '07 #1
4 9423
have you tried Server.HtmlDecode("Page<br>Name")

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"TS" <ma**********@nospam.nospamwrote in message
news:uK**************@TK2MSFTNGP02.phx.gbl...
>I have a headerText for a header column that is "Page<br>Name". it puts a
<brto force a line break, but the < and get encoded to &lt; and &gt;
thus negating its effect as an html control and doesn't respect the line
break

I'm guessing this happens during render. What do i need to do to keep the
line break?


Jul 4 '07 #2
Hi TS,

As for the text in the GridView header column, how did you put in to it?
Statically or dynamically through databinding? I've tested put static test
<br/into TemplateField's HeaderTemplate and it can be displayed correctly
as linebreak. e.g.

==============
...................
<HeaderTemplate>
Page<br />Name
<hr />
Page&lt;br&gt;Name
</HeaderTemplate>

<ItemTemplate>
<%# Eval("description")%>
</ItemTemplate>
</asp:TemplateField>
</Columns>

</asp:GridView>
================

Also, based on the test, if the text is from databinding source and
displayed in TemplateField, since it does not htmlencode it bydefault,
<br/can also display correctly as linebreak.

Please feel free to let me know if there is anything I missed or if you
have any further concerns.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Jul 5 '07 #3

TS wrote:
I have a headerText for a header column that is "Page<br>Name". it puts a
<brto force a line break, but the < and get encoded to &lt; and &gt;
thus negating its effect as an html control and doesn't respect the line
break

I'm guessing this happens during render. What do i need to do to keep the
line break?
If you use BoundField then set HtmlEncode to false
<asp:BoundField DataField="..." HeaderText="Page<br>Name"
HtmlEncode="false"/>

Regards,
Mykola
http://marss.co.ua

Jul 5 '07 #4
TS
that worked. Thanks
"marss" <ma******@gmail.comwrote in message
news:11**********************@n2g2000hse.googlegro ups.com...
>
TS wrote:
I have a headerText for a header column that is "Page<br>Name". it puts
a
<brto force a line break, but the < and get encoded to &lt; and &gt;
thus negating its effect as an html control and doesn't respect the line
break

I'm guessing this happens during render. What do i need to do to keep
the
line break?

If you use BoundField then set HtmlEncode to false
<asp:BoundField DataField="..." HeaderText="Page<br>Name"
HtmlEncode="false"/>

Regards,
Mykola
http://marss.co.ua

Jul 5 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Hans Merkl | last post by:
Hi, I was wondering if it's possible to bind the header text of a GridView column to a method of an object I have. At the moment I am setting the header texts in Page_Load but I was wondering if...
1
by: John_H | last post by:
Re: ASP.NET 2.0 I would like suggestions or code examples on how to collect a variable length list of input data (item# & item quantity specifically). I thought that I could accomplish this...
2
by: rufpirat | last post by:
Hello I'm in the middle of trying to build an "AD phone book", and this being my first try at asp.net, I have a few questions that I hope some of you might be able to help with: 1. Is it...
1
by: Miguel Dias Moura | last post by:
Hello, I have a GridView in my page which is created in runtime. It works fine. My page has 2 Asp Buttons: - The HIDE button makes GridView.Visible = False; - The SHOW button makes...
7
by: WayDownUnder | last post by:
Hello, I have a gridview control bound to a objectdatasource. The primary key column is on the grid but made visible = false. Because the column is invisible I cant get to the cell value when the...
0
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this...
5
by: bbawa1 | last post by:
I have a GetData methd which is returning a table using
5
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
I have a sub in vb.net that adds extra headers to a gridview and it works very well. however, i tried to translate it to c# and i'm getting the header inserting itself over the first datarows and...
2
by: gnewsgroup | last post by:
I have a GridView, in which the header of one column changes depending on the selected value of a DropDownList outside of this GridView. I did this dynamic header through protected void...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.