我正在尝试从数据库中显示网格视图中的数据。我有拖放网格视图并将其绑定到SQL数据源。一切正常,但网格线不显示。请帮帮我。
这是我的代码:
<%@ 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>
答案 0 :(得分:3)
您应该使用以下
<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>
您需要为tr
和td
创建课程,如果您在浏览器中显示th
,则应该查看该课程,如果需要,请按以下步骤创建课程
#MainContent_GridView1 th {
border: solid 1px Black !important;
}
答案 1 :(得分:0)
您也许可以使用gridLines属性:
<asp:GridView GridLines="Both" />