Solved

Gridview skins ASP.Net

Posted on 2008-06-13
3
7,281 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
Suggested Courses

636 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