Solved

Gridview skins ASP.Net

Posted on 2008-06-13
3
7,235 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

680 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