Search code examples
asp.netgridviewheaderword-wrap

Gridview column headers autowrap, how to prevent?


Background:

I have a gridview which is very wide. Some of the headers have a space in them. Because of this the second word of each header is wrapped to the second line. How do I prevent this?

Previous Attempts:

So far, I've tried the following with no luck.

  1. Tried setting the <ItemStyle Wrap="False" /> property in the <boundfield...> tag
  2. Tried setting the HeaderStyle-Wrap="false" attribute in the gridview tag
  3. According to http://www.velocityreviews.com/forums/t292904-gridview-header-wrap.html I needed to remove it from all parent objects. I removed it from all and it still wraps.
  4. I tried setting the width of each column in the databound tag. This did not work.
  5. I've tried setting Wrap="false" in the <headerstyle tag

SceenShot

enter image description here

Question:

How do I prevent the header text in a gridview from autowrapping in a very wide gridview?


Solution

  • What I ended up doing was just creating an arbitrarily large width for the gridview as to let it have enough room. The only downfall to this is that it doesn't dynamically grow and shrink depending on how much space it actually needs. Not a real solution so if somebody has a better solution post it.