Align= "center" effect on data shown gridview rows

36,040

Solution 1

Try this:

<RowStyle HorizontalAlign="Center" />
<AlternatingRowStyle HorizontalAlign="Center" />

Solution 2

Set this property in the gridview: RowStyle-HorizontalAlign="Center"

Solution 3

Have a look at the HTML source in your browser. If you see the align="center" in the offline but not in the online version, something went wrong when publishing your web page (or your browser cache needs to be cleaned, see Crimson's answer).

Share:
36,040
Code Seekers
Author by

Code Seekers

Reading&amp;Coding Freak! A master in both wasting and utilizing time.. Multi-Tasking by nature..

Updated on July 09, 2022

Comments

  • Code Seekers
    Code Seekers almost 2 years

    I am facing a weird situation, I am developing an asp.net website, and I added a gridview control, it is placed inside td tag.

    When I ran the website online, I noticed that the data shown on the rows are shifted to the left while their header tags are centered, so I gave the td an align="center" property, trying to make the data show centered in each column, and that worked perfectly when debugging the site offline.

    However, when I ran the site online (after upload), the data still showed shifted (or aligned left).

    Am I missing something here?

  • Code Seekers
    Code Seekers over 14 years
    Html source showed the align="center" (on the online files :S)
  • Code Seekers
    Code Seekers over 14 years
    MD5 check shows they r the same files, and i used 3 different browsers till now + empty cache, and firebug to check the code..
  • Code Seekers
    Code Seekers over 14 years
    i already tried it before :S sadly for some weird reason it is only affecting the alternating rows..(on html check, the table generated to show the grid view has its alternating tr tags with align=center,while the normal tr tags without it, causing a mis-shift
  • Code Seekers
    Code Seekers over 14 years
    oops my mistake,i was using horizontallaign instead of row style horizontalalign :)
  • Code Seekers
    Code Seekers over 14 years
    +1 for suggestions(thx pretty helpful for future testing :) ),and i guess align=center tag on a td ..doesnt enforce itself on the gridview, so i used the property suggested above ..
  • Code Seekers
    Code Seekers over 14 years
    +1 for suggestions(thx pretty helpful for future testing :) ),and i guess align=center tag on a td ..doesnt enforce itself on the gridview, so i used the property suggested above ..
  • Chandan Kumar
    Chandan Kumar over 9 years
    Thanks. You saved my time :)