为什么不应用GridView CSSClass?

时间:2019-09-27 13:43:41

标签: c# css asp.net gridview

我正在尝试在ASP.net中建立一个新的网页。我正在使用带有分页的gridview,但是我要使用的CSS类没有得到应用。页面其余部分上的CSS可以正常使用,它与该一个gridview有关。我无法通过Google找到答案。请帮忙,任何帮助表示赞赏!

我尝试将CS​​S类更改为class,尝试更改CSS类,尝试从Site Master中移除CSS链接,尝试从Gridview周围移除DIV容器,但是这些都没有差异。

Gridview:

<%--Records of the graphed data --%>
    <div class="Records">
<h4>Shutdown Records</h4>
        <asp:GridView ID="datagrid" runat="server" DataSourceID="SqlDataSource6" CssClass="mGrid" PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt" 
           PageSize="6" AllowPaging="True" OnPageIndexChanging="datagrid_PageIndexChanging" Width="100%">
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource6" runat="server" 
        ConnectionString="<%$ ConnectionStrings:Automation %>"
        ProviderName="System.Data.SqlClient" SelectCommand="select ShutdownDate, ShutdownNotes, StartupDate, StartupNotes, Cast
(
    Round 
    (
        (
        Cast
            (
            SUM(TotalDownTime)as decimal(18, 2)
            )/3600
        )
    , 2 
    ) as decimal(18, 2) 
) as 'Duration of Shutdowns (Hours)' 
from ProductionShutdownRecord 
where Reason like '%'+@Reason+'%'
and ShutdownNotes like '%'+@shutdownNotes+'%'
and StartupNotes like '%'+@startupNotes+'%'
and ShutdownDate &gt;= @startDate
and ShutdownDate &lt;= @endDate
and AMSTaskRelated like 
    CASE 
        when @AMS = 1 then '%1%'
        else '%%'
    END
group by ShutdownDate, ShutdownNotes, StartupDate, StartupNotes
order by shutdowndate asc
">
                <SelectParameters>
                <asp:ControlParameter ControlID="DropDownList1" DefaultValue="Scheduled Release" 
                    Name="Reason" PropertyName="SelectedValue" Type="String" />
                <asp:ControlParameter ControlID="shutdownNotes" ConvertEmptyStringToNull="False" 
                    Name="shutdownNotes" PropertyName="Text" Type="String" />
                <asp:ControlParameter ControlID="startupNotes" ConvertEmptyStringToNull="False" 
                    Name="startupNotes" PropertyName="Text" Type="String" />
                <asp:ControlParameter ControlID="startDate" ConvertEmptyStringToNull="False" 
                    Name="startDate" PropertyName="Text" Type="String" />
                <asp:ControlParameter ControlID="endDate" ConvertEmptyStringToNull="False" 
                    Name="endDate" PropertyName="Text" Type="String" />
                <asp:ControlParameter ControlID="AMSCheck"
                    Name="AMS" PropertyName="Checked"/>
                </SelectParameters>
</asp:SqlDataSource>
</div>

CSS:

/* Gridview Style
-------------------------------------------------------------------------------------------------------------*/
.mGrid {
    width: 100%;
    background-color: #fff;
    margin: 5px 0 10px 0;
    border: solid 1px #525252;
    border-collapse: collapse;
}

    .mGrid td {
        padding: 2px;
        border: solid 1px #c1c1c1;
        color: #717171;
    }

    .mGrid th {
        padding: 4px 2px;
        color: #fff;
        background: #424242 url(grd_head.png) repeat-x top;
        border-left: solid 1px #525252;
        font-size: 0.9em;
    }

    .mGrid .alt {
        background: #fcfcfc url(grd_alt.png) repeat-x top;
    }

    .mGrid .pgr {
        background: #424242 url(grd_pgr.png) repeat-x top;
    }

        .mGrid .pgr table {
            margin: 5px 0;
        }

        .mGrid .pgr td {
            border-width: 0;
            padding: 0 6px;
            border-left: solid 1px #666;
            font-weight: bold;
            color: #fff;
            line-height: 12px;
        }

        .mGrid .pgr a {
            color: #666;
            text-decoration: none;
        }

            .mGrid .pgr a:hover {
                color: #000;
                text-decoration: none;
            }

预期结果:我正在尝试使用此CSS模板: http://atashbahar.com/post/2009-01-23-aspnet-gridview-makeover-using-css

实际结果: 我正在获得纯白色的gridview。

1 个答案:

答案 0 :(得分:1)

为了后代的缘故,以便问题可以得到答案,我将在此处写出解决方案。

使用键盘快捷键Ctrl + Shift + R可以清除浏览器的缓存。现代的浏览器会缓存javascript和css文件等资源,以便下次访问时加载速度更快。如果您对CSS进行了更改却没有出现,则很可能浏览器仍在使用缓存版本。

如果您担心用户看到的是缓存资源而不是更新的资源,请查看cache busting techniques来帮助防止这些问题。