Gridview horizontal gridlines do not show

I cannot get the horizontal gridlines to show up on my gridview. I am creating a printable report so I want black gridlines on a white background. I have tried setting Gridlines="Both" and the tried Gridlines="Horizontal". The best result I can get shows a border around the outside of the gridview and vertical gridlines but the horizontal gridlines will not show up. How can I make this gridview look like a spreadsheet with a black grid?
<asp:GridView GridLines="Both" 
                        ID="gvReport" runat="server" AutoGenerateColumns="False" DataKeyNames="fldReportItemID"
                        DataSourceID="dsReport" EmptyDataText="The Report is Empty" AllowPaging="True" PageSize="40" BorderWidth="1">

Open in new window

ovcbsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Edwin_CCommented:
This will give each cell has black border on the 4 sides.
<asp:GridView GridLines="Both" 
                        ID="gvReport" runat="server" AutoGenerateColumns="False" DataKeyNames="fldReportItemID"
                        DataSourceID="dsReport" EmptyDataText="The Report is Empty" AllowPaging="True" PageSize="40" CellPadding="4" CellSpacing="1" BackColor="black" RowStyle-BackColor="white"
                HeaderStyle-BackColor="white" FooterStyle-BackColor="white">

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ovcbsAuthor Commented:
This produced exactly the look I was needing. Thank you.
0
RobSampsonCommented:
ovcbs, can you please accept Edwin C's answer to close this question?

Thanks,

Rob.
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

ovcbsAuthor Commented:
I have found that while this works in ie7 it does not work in Firefox. Any further comments or help?
0
RobSampsonCommented:
I'm not much of a Web programmer, but is ASP supported in FireFox? I've heard not....
See if this works for JavaScript.

Regards,

Rob.
<javascript:GridView GridLines="Both" 
                        ID="gvReport" runat="server" AutoGenerateColumns="False" DataKeyNames="fldReportItemID"
                        DataSourceID="dsReport" EmptyDataText="The Report is Empty" AllowPaging="True" PageSize="40" CellPadding="4" CellSpacing="1" BackColor="black" RowStyle-BackColor="white"
                HeaderStyle-BackColor="white" FooterStyle-BackColor="white">

Open in new window

0
ovcbsAuthor Commented:
This is ASP.NET not ASP. You cannot just specify javascript as a replacement for asp as the gridview is an asp.net component which is "wired" as such.  As for the compatibility with firefox, asp.net is handled on the server and a mix of html/javascript is passed to the browser. Firefox never "sees" any ASP.NET code. Hope this clarifies.
0
RobSampsonCommented:
Hmmm, not familiar with ASP.NET sorry.....Firefox has an inbuilt debugger doesn't it?  Can you use that do debug the script?

Rob.
0
Edwin_CCommented:
My firefox has no problem in seeing the border.  I used this code to test.  Do you see the border?

    <form id="form1" runat="server">
        <div>
            <asp:GridView GridLines="Both" ID="gvReport" runat="server" AutoGenerateColumns="true"
                EmptyDataText="The Report is Empty" AllowPaging="True"
                PageSize="40" CellPadding="4" CellSpacing="1" BackColor="black" RowStyle-BackColor="white"
                HeaderStyle-BackColor="white" FooterStyle-BackColor="white">
            </asp:GridView>
        </div>
    </form>
 
 
code behind:
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("name", typeof(string));
            dt.Columns.Add("country", typeof(string));
            dt.Rows.Add(new object[] { "John", "US" });
            dt.Rows.Add(new object[] { "Mary", "UK" });
            gvReport.DataSource = dt;
            gvReport.DataBind();
        }
    }

Open in new window

0
RobSampsonCommented:
Sorry I don't Firefox on my system.  You may be able to work around it by setting CellPadding to 0, CellSpacing to 1, BackColor to the color you want the grid-lines to be, and GridLines to False:

Regards,

Rob.
<asp:GridView GridLines="False" 
                        ID="gvReport" runat="server" AutoGenerateColumns="False" DataKeyNames="fldReportItemID"
                        DataSourceID="dsReport" EmptyDataText="The Report is Empty" AllowPaging="True" PageSize="40" CellPadding="0" CellSpacing="1" BackColor="black" RowStyle-BackColor="white"
                HeaderStyle-BackColor="white" FooterStyle-BackColor="white">

Open in new window

0
ovcbsAuthor Commented:
After testing Edwin C's code and seeing that it worked fine I dug back into my code. Some 85 lines below the gridview declaration, just befor the gridview close were 2 lines:
                        <RowStyle BackColor="White" BorderColor="White" BorderStyle="None" Font-Size="Small" />
                        <HeaderStyle BackColor="White" BorderColor="White" Font-Size="Small" BorderWidth="0px" />
I'm not sure how they got there but they were causing the problem! Thank you all for your help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.