Don't change the title text color in a gridview with CSS

I am using asp.net c #. I use gridview to display data. I control all formatting through CSS. In gridview, I define itemtemplate + edititemtemplate + footertemplate and sort by the binding column in the template field. My problem is the name of the column, which dispalay as the header, which does not change with CSS, the font size, the type all goes well, but the fore color is fixed, because Blue is any organ that helps me, how can I change the forecolor of the header, which allows sorting.

My code looks like this: asp: TemplateField HeaderText = "Slsmn No." HeaderStyle-Cssclass = "GridHeaderStyle" SortExpression = "Profile_Var"

The problem is "Slsmn No." Display blue color and below the line, but in css I gave the color: red

thanks

+3
source share
5 answers

The CSS class that you assigned (GridHeaderStyle) applies to the header cells, not the header links. It looks like the default link color is applied.

Add the following to your CSS file:

.GridHeaderStyle a {color: red;}

This should change the color of the link in the headers.

Hope this helps!

+3
source

At first I tried Jeremy's solution, but it did not work for me. This is because the generated .asp code forces the tag <style="color: #333333">in the header when you make it sortable.

Here's how to solve the problem:

.GridHeaderStyle a {color: white!important}

An important classifier overrides the style that asp inserts.

+1

, CSS, .

:

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

This post still does not have a better answer. I found below code on the same forum that ismailperim responded to.

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

He will surely solve the problem.

0
source

ANY of the solutions did not work. I solved this problem very simply. Added the "HeaderStyle" attribute at the end of the grid definition. What does it look like:

...
...

0
source

Source: https://habr.com/ru/post/1704922/


All Articles