Sandeep Reddy K.
Sandeep Reddy K.

Reputation: 1011

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>

Upvotes: 2

Views: 3141

Answers (2)

Saket Kumar
Saket Kumar

Reputation: 4835

You can perhaps use gridLines property:

 <asp:GridView GridLines="Both" />

Upvotes: 1

शेखर
शेखर

Reputation: 17614

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;
     }

Upvotes: 3

Related Questions