【发布时间】:2020-01-27 20:29:58
【问题描述】:
我正在尝试在 ASP.net 中设置一个新网页。我正在使用带有分页的gridview,但是我尝试使用的CSS类没有得到应用。页面其余部分的 CSS 正在工作,它只是与这个 gridview 相关。我一直无法通过谷歌找到答案。请帮助,感谢任何帮助!
我已尝试将 CSS 类更改为类,我已尝试更改 CSS 类,我已尝试从 Site Master 中删除 CSS 链接,我已尝试从 Gridview 周围删除 DIV 容器,但这些都没有区别。
网格视图:
<%--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 >= @startDate
and ShutdownDate <= @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
实际结果: 我得到一个纯白色的网格视图。
【问题讨论】:
-
您能给我们提供生成的 HTML 吗?如果您还没有清除缓存,我首先会尝试清除缓存(在大多数主流浏览器中按
Ctrl+Shift+R即可) -
哇,清除我的缓存成功了!但为什么这行得通?你能解释一下吗?
-
当然!因此,现代浏览器会缓存 javascript 和 css 文件等资源,以便下次访问时加载速度更快。如果您对 CSS 进行了更改并且它们没有出现,则很有可能您的浏览器仍在使用缓存版本。按
Ctrl+Shift+R会清除那些缓存的对象并强制浏览器抓取一个新副本! -
你是救命稻草,非常感谢!
-
乐于助人!查看cache busting 之类的内容或如何使用开发人员工具禁用浏览器缓存,让您的生活更轻松