[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5396
  • Last Modified:

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

0
ovcbs
Asked:
ovcbs
  • 4
  • 4
  • 2
1 Solution
 
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
 
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now