473,287 Members | 1,899 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,287 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 11515
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)...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.