Formatting a GridView table

Posted on 2007-10-11
Last Modified: 2008-01-09
I've chosen an autoformat style for my GridView control and  then played around  more with the Properties but there are still some things I'd like to do that I don't see offered.

1. I'd like a double vertical line separating the left-most column from the rest of the table.
2. I'd like to change the color of the vertical lines.
3. I'd like a Title row above  the headings row that announces the name of the table
4. I've  turned on sorting so the headings are links that are underlined.  I don't want them to be underlined.

Can anyone tell he how to do any of the above?

Thanks for any input.

Question by:steva
    LVL 7

    Expert Comment

    do some research on stylesheets and tables
    LVL 2

    Expert Comment

    4)If you don't want underline in the hyperlink then for anchor,  take ' text-decoration : none' in style sheet
    3) For title row, put the gridview under some table and then in first row take <th> and in second row <td> put the gridview.
    2) that you can do by creating  the style for td and by setting the border color.
    1) for this use border width, cell padding , cell spacing

    Author Comment


    The problem here seems to be that the grid view isn't a table until it's rendered into HTML and when ASP.Net  renders it into HTML the styles are put inline.  Therefore, any style ASP.NET  inserts can't be overidden with a style sheet or an  internal <style>...</style> section in the header since these are overridden by any  inline style definitions.  

    The link underline was easy to get rid of by adding an internal style section definition


    This worked because ASP.NET hadn't specified any specific text-decoration inline that would block this.

     For my  "Title row" I just put some h2 text centered above the GridView.

    I was able to change the color of the vertical lines with a td style, as you suggested, but I think this only worked because ASP.NET set the color in the table element, rather than the cells, which gets overridden by any cell styles. If ASP.NET had set the td styles I don't think I could  have changed  it.
    The double vertical lines to the right of only the first column I wasn't able to do because I haven't figured out a CSS selector for td and th that only picks the left most column.

    When I wrote the question I was really hoping to find a way to get better control over the GridView formatting and do all the things I wanted at that level.  Having to override the GridView formatting with CSS,when you can,  is pretty ugly!

    Is this the way you see things?

    LVL 2

    Accepted Solution


    For the double lines, it won't be possible thru css.
    better to do it in code behind. find the cell[0] and cell[1].
    set cell[0].rightborder width and cell[1] left border width.  then you can achieve it.

    We don't have much control over gridview. In order to make the things work you need to do the tweaking either in css or in code behind.


    Author Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now