Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 677635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:03:40+00:00 2026-05-14T01:03:40+00:00

I want to alternate rowcolor in a GridView, using pure CSS, ie: I don’t

  • 0

I want to alternate rowcolor in a GridView, using pure CSS, ie: I don’t want to use asp.net themes; I’d rather not have to use jQuery, or define define AlternatingRowStyle-BackColor on each gridview (unless there’s a reason I must).

Here’s my CSS (that isn’t working):

.gridView {font-size:11px
}

.gridView tr:nth-child(even) {background-color: #FFF}
.gridView tr:nth-child(odd) {background-color: #FFCC00}

.gridView tr:nth-child(even) td {background-color: #FFF}
.gridView tr:nth-child(odd) td {background-color: #FFCC00}

(I included the .gridView {font-size:11px} just to confirm I am using the proper CssClass.)

Is this not possible, or am I doing something wrong.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:03:40+00:00Added an answer on May 14, 2026 at 1:03 am

    You are using CSS3, which is not supported by all browsers. To do this in a cross-browser compatible way you need to use alternating class, jQuery, or some other method to do this.

    The alternating class is a fairly elegant way to do so, IMHO.

    UPDATE: This shows the gridview way:

    <asp:gridview id="CustomersGridView" runat="server">        
        <RowStyle CssClass="Row" />
        <AlternatingRowStyle CssClass="AltRow" />
    </asp:gridview>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First I would like to explain why I want to use alternate Blackberry Persistance
I want to assign alternate class to rows in a table. I am using
I'm using an alternate keyboard layout (Colemak) and I want to move the universal-argument
Alternate method to use mysql date_sub(now(),interval 1 day) in php? Actually I want this
I want to get my session variables in my model. Im not using Auth
How do I alternate HTML table row colors using JSP? My CSS looks something
What is the proper HTML if I want to alternate the number of cells
I have an Ul of item. I want to alternate there background color here
Basically, what I want is to use an alternative to the login cookies as
want to open pdf file when a user clicks on hyperlink shown in gridview

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.