473,657 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="Rev enue <br /> Impact", but that doesn't work. Any help would
be appreciated.
--
Thanks in advance,

sck10
<asp:BoundFie ld DataField="Reve nueImpactType"
HeaderText="Rev enue Impact"
SortExpression= "RevenueImpactT ype"
ItemStyle-HorizontalAlign ="Left"
ItemStyle-VerticalAlign=" Top"
ItemStyle-Width="15%"
FooterStyle-BorderWidth="0" />
May 18 '06 #1
2 11590
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 CustomersGridVi ew_DataBound(ob ject sender, EventArgs e)
{
foreach (TableCell c in CustomersGridVi ew.HeaderRow.Ce lls)
{
c.Text = HttpUtility.Htm lDecode(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:BoundFie ld DataField="Reve nueImpactType"
HeaderText="Rev enue Impact"
HtmlEncode="fal se"
SortExpression= "RevenueImpactT ype"
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
3474
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 I can do with databinding. thanks Hans Merkl
4
36430
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 first line, and the other half right under it, on the second line. How can I accomplish this feat? P.S. Right now I can only get the label to show the sentence to me all on
0
1409
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 Header Text value? <asp:BoundField DataField="Price" HeaderText="This phrase had four words" SortExpression="Price" />
2
5787
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 ... etc .... > does not prevent the header text from wrapping.
3
17324
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. Anyone know the command for this? Here's what I want to do: rst2("Change") = rst2("Change") & **LINE BREAK *** & "Autopropagated Change to..."
8
31968
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 the specific header text. i want to load a new text from a global resource file. what i'm actually trying to do and is not working :
4
9450
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 respect the line break I'm guessing this happens during render. What do i need to do to keep the line break?
7
12949
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
2071
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) { col.HeaderText = GetString(col.HeaderText); } However, no matter where I place that code, the header texts return to their original value, and that's what's being displayed.
0
8413
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8324
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8740
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8513
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6176
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.