gridview stylesheet code?

Posted on 2011-10-20
Last Modified: 2012-05-12
Following is some of the stylesheet code supplied by our graphic designer for a table on my web form.  She was working from a screenshot, but what I was really using is a gridview.

How can I achieve the same visual effects on a gridview?  Ideally, I should be able to add the code you give me into her style sheet and then just set my gridview CSSClass to the new type.

/* --[ TABLE/GRID ]----------------------------------------------------- */
#main #tblData {
	width: 100%; }

#main #tblData td {
	vertical-align: top; 
	padding: 5px;
	border: 1px solid #d1d7e2; }

#main #tblData td.edit {
	font-size: 10px;
	width: 20px;
	background-color: #d1d7e2; }

#main #tblData tr.altrow {
		background-color: #e6edfc; }

#main #tblData tr.hover td {
	background-color: #d1d7e2;
	cursor: pointer; }
#main #tblData thead tr td {
	border: 0px;
	font-weight: bold;
	color: #666666;
	background-color: #ffffff;

Open in new window

Question by:codefinger
    LVL 28

    Accepted Solution

    You can add all these CSS values to the Skin file in the project. A simple example of my is below. Don't forget to reference the skin file in your web.config pages section.

    <asp:GridView runat="server" BackColor="White" >
    	<AlternatingRowStyle BackColor="#D1D1D1" />
    	<HeaderStyle BackColor="Black" ForeColor="White" Font-Bold="true" />

    Open in new window


    Author Comment

    Interesting.  I have not used skins before....first time hearing of them.

    What would the web config entry look like?

    LVL 28

    Expert Comment

    <pages theme="MainStyle"/> with "MainStyle" being the name of your skin file.

    Author Comment

    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

    Parser Error Message: Content ('<HeaderStyle BackColor="Black" ForeColor="White" Font-Bold="true"') does not match any properties within a 'System.Web.UI.WebControls.GridView', make sure it is well-formed.

    Source Error:

    Line 16: <asp:GridView runat="server" SkinId="gridViewSkin" BackColor="Red" >
    Line 17:    <AlternatingRowStyle BackColor="#D1D1D1" />
    Line 18:       <HeaderStyle BackColor="Black" ForeColor="White" Font-Bold="true"
    Line 19: </asp:GridView>


    Source File: /MyChartInternal/App_Themes/VSSkin/    Line: 18

    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
    LVL 28

    Expert Comment

    You're missing the " />" at the end of the line.

    Author Comment

    DOH!  Having a Homer moment....sorry....

    Author Closing Comment

    Works beautifully and taught me something I did not know before...nice...

    strickdd....having a problem with a radiobuttonlist I am sure you can help me with, but I will shortly be asking about that in a related question...please keep an eye out for it.


    Featured Post

    Javascript: Crash Course

    Javascript is not only emerging as the most important language to know, it's flexibility is unique. With Javascript being deployed on the web, mobile and even the desktop this is the one language that all technologists need to know.

    Join & Write a Comment

    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    728 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

    21 Experts available now in Live!

    Get 1:1 Help Now