grid lines are not displaying in grid view

I am trying to display data in grid view from database. I have drag and drop grid view and bound it to SQL data source.Everything is working fine but grid lines are not displaying. Please help me out this.

here is my code:

<%@ Page Title="" Language="C#" MasterPageFile="~/secured/secured.Master" AutoEventWireup="true" CodeBehind="GetReport.aspx.cs" Inherits="Activity.secured.WebForm1" EnableEventValidation="false"%>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
    <style type="text/css">
    #MainContent_GridView1 {
    border: solid 1px Black !important;
   }
        </style>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <div style="overflow-x:scroll;width:1100px">
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
         AutoGenerateColumns="False" DataKeyNames="ACTIVITY_ID" 
         DataSourceID="SqlDataSource1" CaptionAlign="Top" AllowSorting="True" 
         CellPadding="0" CellSpacing="1" HorizontalAlign="Center">
        <Columns>
            <asp:BoundField DataField="ACTIVITY_ID" HeaderText="ACTIVITY_ID" ReadOnly="True" SortExpression="ACTIVITY_ID" >
            </asp:BoundField>
            <asp:BoundField DataField="ACTIVITY_TYPE" HeaderText="ACTIVITY_TYPE" SortExpression="ACTIVITY_TYPE" >
            </asp:BoundField>
            <asp:BoundField DataField="TICKET_ID" HeaderText="TICKET_ID" SortExpression="TICKET_ID" >
            </asp:BoundField>
            <asp:BoundField DataField="TICKET_CATEGORY" HeaderText="TICKET_CATEGORY" SortExpression="TICKET_CATEGORY" />
            <asp:BoundField DataField="TICKET_DESCRIPTION" HeaderText="TICKET_DESCRIPTION" SortExpression="TICKET_DESCRIPTION" />
            <asp:BoundField DataField="ACTIVITY_DESCRIPTION" HeaderText="ACTIVITY_DESCRIPTION" SortExpression="ACTIVITY_DESCRIPTION" />
            <asp:BoundField DataField="MODULE" HeaderText="MODULE" SortExpression="MODULE" />
            <asp:BoundField DataField="PRIORITY" HeaderText="PRIORITY" SortExpression="PRIORITY" />
            <asp:BoundField DataField="RESOURCE_NAME" HeaderText="RESOURCE_NAME" SortExpression="RESOURCE_NAME" />
            <asp:BoundField DataField="CREATION_DATE" HeaderText="CREATION_DATE" SortExpression="CREATION_DATE" />
            <asp:BoundField DataField="ASSIGNMENT_DATE" HeaderText="ASSIGNMENT_DATE" SortExpression="ASSIGNMENT_DATE" />
            <asp:BoundField DataField="COMPLITION_DATE" HeaderText="COMPLITION_DATE" SortExpression="COMPLITION_DATE" />
            <asp:BoundField DataField="STATUS" HeaderText="STATUS" SortExpression="STATUS" />
            <asp:BoundField DataField="REMARKS" HeaderText="REMARKS" SortExpression="REMARKS" />
            <asp:BoundField DataField="EFFORTS" HeaderText="EFFORTS" SortExpression="EFFORTS" />
        </Columns>
        <EditRowStyle BackColor="White" BorderColor="Black" BorderStyle="Solid" BorderWidth="0px" />
    </asp:GridView>
        </div>
    <div>
        <asp:Button ID="btnExport1" runat="server" Text="Export to Excel" OnClick="btnExport1_Click"/>
    </div>

    </asp:SqlDataSource>
</asp:Content>

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You should use as following

<style type="text/css">
    #MainContent_GridView1 {
        border: solid 1px Black !important;
     }
    #MainContent_GridView1 tr {
        border: solid 1px Black !important;
     }
     #MainContent_GridView1 td {
        border: solid 1px Black !important;
     }
 </style>

You need to create class for your tr and td you should also look if you have th is render on your browser if so you need to create class as follow

     #MainContent_GridView1 th {
        border: solid 1px Black !important;
     }

Method 2

You can perhaps use gridLines property:

 <asp:GridView GridLines="Both" />


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x