簡體   English   中英

不通過使用 CSS 更改 Gridview 中的 Header 文本顏色

[英]Not Changing Header Text Color In Gridview through using CSS

我正在使用 asp.net c#。 我正在使用 gridview 來顯示數據。 我通過 CSS 控制所有格式。 在 gridview 中,我定義了 itemtemplate + edititemtemplate + footertemplate 並通過模板字段的綁定列進行排序。 My problem is the column name which dispalay as header that color is not changed through CSS, font size,type all things going ok but fore color is fix as Blue is any body help me out how can i change forecolor of header which is allow to排序。

我的代碼看起來像:asp:TemplateField HeaderText="Slsmn No." HeaderStyle-CssClass="GridHeaderStyle" SortExpression="Profile_Var"

問題是“Slsmn No.”。 顯示藍色和下划線,但在 css 我給了顏色:紅色

謝謝

您分配的 CSS class (GridHeaderStyle) 正在應用於 header 單元格,而不是 Z099FB995346E3Z 鏈接。 聽起來好像正在應用默認鏈接顏色。

將以下內容添加到您的 CSS 文件中:

.GridHeaderStyle a {color: red;}

這應該會更改標題中的鏈接顏色。

希望這可以幫助!

起初我嘗試了 Jeremy 的解決方案,但它對我不起作用。 這是因為生成的 .asp 代碼強制在 header 中使用<style="color: #333333">標記,當您使其可排序時。

以下是解決問題的方法:

.GridHeaderStyle a {color: white!important}

.important 限定符將覆蓋 asp 放入的樣式。

發生這種情況是因為您尚未定義 CSS 規則,該規則說明了有關鏈接顏色的任何內容。

將以下內容添加到您的樣式表中:

.GridHeaderStyle a {
    color: #f0f; /* or whatever */
}

這篇文章仍然沒有最佳答案。 我在 ismailperim 回答的同一個論壇中找到了以下代碼。

.GridStyle
{
    border: 6px solid rgb(217, 231, 255);
    background-color: White;
    font-family: arial;
    font-size: 12px;
    border-collapse: collapse;
    margin-bottom: 0px;
}
.GridStyle tr
{
    border: 1px solid rgb(217, 231, 255);
    color: Black;
    height: 25px;
}
/* Your grid header column style */
.GridStyle th
{
    background-color: rgb(217, 231, 255);
    border: none;
    text-align: left;
    font-weight: bold;
    font-size: 15px;
    padding: 4px;
    color:Black;
}
/* Your grid header link style */
.GridStyle tr th a,.GridStyle tr th a:visited
{
        color:Black;
}
.GridStyle tr th, .GridStyle tr td table tr td
{
    border: none;
}

.GridStyle td
{
    border-bottom: 1px solid rgb(217, 231, 255);
    padding: 2px;
}

肯定能解決問題

沒有任何解決方案。 我非常簡單地解決了這個問題。 在網格定義的末尾添加了“HeaderStyle”屬性。 它的樣子:

... </Columns>
...
<HeaderStyle ForeColor="Red" />
<SelectedRowStyle ...
</asp:GridView> ...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM