Solved

Gridview skins ASP.Net

Posted on 2008-06-13
3
7,203 Views
Last Modified: 2010-04-21
I'm trying to create a skin for a gridview.  The problem is that the grid lines are the default color, not the color they should be as specified by my style sheet.  
Here's what I have:
In Skin file
<asp:GridView runat="server" SkinId="GridViewReportSkin"
    BorderColor="#996633" BorderStyle="Solid" BorderWidth="1px">  
    <HeaderStyle CssClass="MasterGridViewHeader"/>
    <RowStyle CssClass="MasterGridViewCells"/>
</asp:GridView>

In the Style sheet
.MasterGridViewHeader
{
    border-color: #DAC9A9;
    border-style: solid;
    background-color: #DAC9A9;
}

.MasterGridViewCells
{
   border-color: #DAC9A9;
   border-width: 2px;
    border-style: solid;
    vertical-align: top;
 
}

In aspx page:

<asp:GridView ID="GridView1" runat="server" DataSourceID="ObjectDataSource1"
                    AutoGenerateColumns="False" onrowdatabound="GridView1_RowDataBound"
                    ShowFooter="True" SkinID="GridViewReportSkin">
                    <Columns>
                        <asp:BoundField DataField="OrderDate" DataFormatString="{0:MM/dd/yyyy}"
                            HeaderText="Date" />
                       ........
                   </Columns>
</asp:GridView>

If I do the following for the bound field in the aspx page it works.

<asp:BoundField DataField="OrderDate" DataFormatString="{0:MM/dd/yyyy}"
                            HeaderText="Date" >
 <ItemStyle CssClass="MasterGridViewCells"/>
</asp:BoundField>

But I dont' what to have to specify the CssClass for each bound field in the grid view.  I would like to handle it in the skin file.  Is there a way to do this?  *Note the "vertical-align: top;" does work in the skin file.

0
Comment
Question by:weimha
  • 2
3 Comments
 
LVL 21

Expert Comment

by:naspinski
ID: 21780771
try adding this:
.MasterGridViewCells tr td, .MasterGridViewHeader tr td

{

    border-color: #DAC9A9;

    border-style: solid;

    background-color: #DAC9A9;

}

Open in new window

0
 
LVL 21

Accepted Solution

by:
naspinski earned 500 total points
ID: 21780795
nevermind that one, I forgot that they render in the TRs
.MasterGridViewCells td, .MasterGridViewHeader td

{

    border-color: #DAC9A9;

    border-style: solid;

    background-color: #DAC9A9;

}

Open in new window

0
 

Author Closing Comment

by:weimha
ID: 31466990
Worked Great.  Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating a CSS block that only applies to printing By default, all of your CSS applies to every possible view of your page - whether on screen, printed, landscape, touch-screen, or whatever.  You can, however, add CSS that only applies under certai…
This is a how to build your own CSS3 slideshow and when I say CSS3 I mean just CSS with no javascript in sight! There a few examples online of how to do this but most just show you an example without any explanation, others make it more complicat…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now