I’ve been a while without dealing with html issued, specially with aspx controls since I was working till now with asp and vb6. Well, after this intro I’ll pass to the question:
I’ve found a way to stylize a GridView using CSS, this way:
<asp:GridView ID="myGrid" runat="server" CssClass="workGrid">
and then I specify the different sections styles from the CssClass, this way:
.workGrid th /* for the header */
{
BORDER-BOTTOM: 2px solid black;
BORDER-LEFT: 0px none;
BORDER-RIGHT: 0px none;
BORDER-TOP: 0px none;
FONT-SIZE: 9pt;
FONT-WEIGHT: bolder;
}
.workGrid td /* for the body */
{
border-style: none;
border-width: 0px;
}
The issue now is than I can’t stylize the cells within the header, just can change the entire header through the “th” style…
Could someone give me a hand on this? Thanks!
Thanks to the response by Ryan I realized that my understanding was not correct.
I was trying to stylize the header of my gridview by creating a new style for every “th” in my page, and it was working 90% fine. But I couldn’t set the border for each cell in the header, rather I was setting the border for the entire row (header).
This is what I wanted to do…
http://tinypic.com/r/4l3m1j/6
And this is what I was getting…
http://tinypic.com/r/29f5oub/6
Therefore I thought that within the “th” there are many “td” (wrong) and I should set the style for each “td” within the “th”.
I realized it was not as I thought when I saw the generated code and how the gridview was being rendered.
Actually the issue was that the gridview was rendered as a table with the property cellspacing set as 0.
Finally, I solved the problem by setting the property cellspacing of the gridview.