How do I set the color of the horizontal lines between rows in a asp.net gridview?

19,032

Add a css class to the GridView CssClass="someClass", then do something like:

Update: Try something like this:

  <style>
        .someClass tr td
        {
            border-top: 1px solid red;
            border-bottom: 1px solid red;
        }
    </style>

 <asp:GridView ID="GridView1" runat="server" ... GridLines="Horizontal" CssClass="someClass">

And you will get red grid lines.

Share:
19,032
Lill Lansey
Author by

Lill Lansey

I'm the web developer at work. I do everything from asking the users the right questions to creating the UI to setting up the SqlServer backend. What technology will I learn today?

Updated on July 13, 2022

Comments

  • Lill Lansey
    Lill Lansey almost 2 years

    Using asp.net 3.5 Gridview control, visual studio 2008.

    I have played with all the css border controls and can't set the color of the horizontal line between rows in an asp.net gridview. The color of the line seems to be defaulting to white. The only way those rows are visible are if the background color of the gridview is set to a dark color that contrasts with the white lines.

    I have set Gridlines=Horizontal but cant find a way to set Gridlines color.

    The gridview bordercolor attribute only affects the outermost border around the entire gridview.

    I would rather not do this in javascript or jquery.

  • Lill Lansey
    Lill Lansey over 14 years
    class affects font size etc but not border size or color.
  • Lill Lansey
    Lill Lansey over 14 years
    backcolor affects the color of the cell; the border remains white.
  • RichardOD
    RichardOD over 14 years
    Try again now- I just knocked up a quick example with a drag and drop GridView and it worked on my machine.
  • Lill Lansey
    Lill Lansey over 14 years
    Thank you! That did it. This had me going nuts.