Lill Lansey
Lill Lansey

Reputation: 4915

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

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.

Upvotes: 4

Views: 19671

Answers (3)

Lill Lansey
Lill Lansey

Reputation: 4915

Added info for anyone who needs it.

RichardOD's answer worked. Thank you RichardOD!

However, solving this problem caused another:

I was dynamically adding a radiobuttonlist to some of the rows and the radiobuttonlist control displayed with additional (ugly) horozontal lines.

I had to create another css class, as

.control tr td
{
border-style:none;
}

and in my C# code behind when generating the control, I added :

RadioButtonList rb = new RadioButtonList()
 ...
 rb.CssClasss="control";

Upvotes: 0

RichardOD
RichardOD

Reputation: 29157

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.

Upvotes: 8

Degan
Degan

Reputation: 989

I think you want to set the "BackColor"

Upvotes: 0

Related Questions