Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
142 views
in Technique[技术] by (71.8m points)

c# - 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>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...