views:

1171

answers:

4

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.

+1  A: 

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.

RichardOD
class affects font size etc but not border size or color.
Lill Lansey
Try again now- I just knocked up a quick example with a drag and drop GridView and it worked on my machine.
RichardOD
Thank you! That did it. This had me going nuts.
Lill Lansey
A: 

I think you want to set the "BackColor"

Degan
backcolor affects the color of the cell; the border remains white.
Lill Lansey
This changes the gridline color for me...BackColor="#FF33CC" BorderColor="#FF9900" BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2" DataSourceID="AccessDataSource3" ForeColor="Black"
Degan
A: 

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";
Lill Lansey
A: 

In order to set the color of grid line you have to add the bordercolor attribute in the code behind and then set the value GridView.Attributes.Add("bordercolor", "#acc0e9"); For further detail please see below link

http://asimsajjad.blogspot.com/2009/05/gridview-gridline-color.html

Asim Sajjad