473,395 Members | 1,761 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,395 software developers and data experts.

Line break in GridView Header Text

Hello,

I have the following for a GridView. How do you break the HeaderText into
two lines. I tried using:

HeaderText="Revenue <br /> Impact", but that doesn't work. Any help would
be appreciated.
--
Thanks in advance,

sck10
<asp:BoundField DataField="RevenueImpactType"
HeaderText="Revenue Impact"
SortExpression="RevenueImpactType"
ItemStyle-HorizontalAlign="Left"
ItemStyle-VerticalAlign="Top"
ItemStyle-Width="15%"
FooterStyle-BorderWidth="0" />
May 18 '06 #1
2 11535
Hi,

Thank you for posting!

Based on my understanding, the question is: how to prevent the GridView
from encoding HeaderText property. If there's anything I misunderstood,
please feel free to post here.

Well, while we cannot prevent GridView from encoding the HeaderText
property, we can decode it back after the DataBinding is complete. We can
do this in the DataBound event:

protected void CustomersGridView_DataBound(object sender, EventArgs e)
{
foreach (TableCell c in CustomersGridView.HeaderRow.Cells)
{
c.Text = HttpUtility.HtmlDecode(c.Text);
}
}

If there is any unclear/you have any more concerns, please feel free to
reply here. I am glad to work with you on it.

Thanks.
Regards,

Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

May 19 '06 #2
Hi,

Sorry for the last post. I overlooked that there is a property named
"HtmlEncode" in BoundField to indicate whether field values are
HTML-encoded before they are displayed.

So the correct answer to your question would be:

<asp:BoundField DataField="RevenueImpactType"
HeaderText="Revenue Impact"
HtmlEncode="false"
SortExpression="RevenueImpactType"
ItemStyle-HorizontalAlign="Left"
ItemStyle-VerticalAlign="Top"
ItemStyle-Width="15%"
FooterStyle-BorderWidth="0" />

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 2 '06 #3

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...
4
by: Drew Leon | last post by:
I am learning how to program using Visual Studio 2005 (I chose Visual Basic to start). My question is: I have a sentence which I want to split in two. I would like half the sentence on the...
0
by: sloan | last post by:
When defining a GridView column...and the header for that column <asp:BoundField DataField="Price" HeaderText="The Price" SortExpression="Price" /> is there a way to force a <br/> in the...
2
by: Mark Rae | last post by:
Hi, Is there a bug in the GridView control specifically related to wrapping of header text...? E.g. the following tag <asp:GridView HeaderStyle-Wrap="false" ID=gvListUsers runat=server ......
3
by: lmawler | last post by:
Hi all, I know when I do data entry, I can force a line break in a text box by using Control & Enter. I'm trying to insert a line break in a field (that behaves like Control Enter) from VB. ...
8
by: fredd00 | last post by:
hi i'm trying to change the gridview columns header text the columns are not auto generated, i have set specific headertext values for each column i want to change the header text based on...
4
by: TS | last post by:
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...
7
by: rote | last post by:
I would like to make my Gridview header dynmic i.e databinded from database.. I want my users to be able to change the headers on the fly.. Any ideas?
1
by: Amit00 | last post by:
Hi, I have an ascx file with a gridview, and I need to change the header text of the gridview's column in the code-behind. Something like that: foreach (DataControlField col in GridView1.Columns)...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.