Link to home
Start Free TrialLog in
Avatar of rpm
rpmFlag for United Kingdom of Great Britain and Northern Ireland

asked on

GridView vertical column headings without breaking the sort functionality

I have a GridVIew table in an ASP.net project. I need the column headings to be oriented vertically.

I have achieved this with the following steps:

1) Adding the following into the head:

    <style>
        .verticaltext
        {
            writing-mode: vertical-rl;
        }
    </style>

2) Adding the following into gvResults_DataBound:

For C = 2 To 16
      gvResults.HeaderRow.Cells(C).Text = "<div class=""verticaltext"">" & gvResults.Columns(C).HeaderText & "</div>"
Next

This has the required visual effect, but unfortunately breaks the ability to click the column heading to sort the table.

Can anyone suggest a way to re-orient the header text without breaking the sort functionality.

Thanks,

Richard
Avatar of Camillia
Camillia
Flag of United States of America image

It's been a while since I've used Gridviews but can you use

      <ItemStyle  CssClass="mystyle" />

with css
.mystyle
{vertical-align: <something here>}

OR

<asp:TemplateField ItemStyle-VerticalAlign="....."
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.