Solved

Gridview skins ASP.Net

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
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…

743 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

15 Experts available now in Live!

Get 1:1 Help Now