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 9224217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:15:49+00:00 2026-06-18T04:15:49+00:00

In my website, I have a page with a Gridview that I use to

  • 0

In my website, I have a page with a Gridview that I use to display some data. I capture the RowDataBound event, to find out if certain text is present in a cell. If it is, I color it green, else I color it red.

Here’s the problem: the Gridview has horizontal gridlines only. When I change the color of the cell in RowDataBound (I’m actually changing the class), the gridlines take on the color applied. I cannot revert it back, no matter what I try (looping through all cells and setting border-color). Please help.

protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        for (int i = 2; i <= 3; i++)
        {
            if (e.Row.Cells[i].Text.Contains("monkey"))
            {
                e.Row.Cells[i].Attributes.Add("class", "monkey bold");
            }
            else
            {
                e.Row.Cells[i].Attributes.Add("class", "nomonkey bold");
            }
        }
    }

}

The style is as follows:

.monkey
{
    color: #009900;
    border-color: black;
}

.nomonkey
{
    color: red;
    border-color: black;
}

The border-color property seems to have no effect.

The GridView is defined as:

                        <asp:GridView ID="GridView2" runat="server" AllowSorting="False" GridLines="Horizontal" AutoGenerateColumns="false" CellPadding="4" OnRowDataBound="GridView2_RowDataBound" OnDataBound="GridView2_DataBound" CssClass="reportGrid"> 
                        <FooterStyle BackColor="#2F76B8" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#2F76B8" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                        <RowStyle BackColor="#FFFFFF" ForeColor="#222222" HorizontalAlign="Center" />
  • 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-06-18T04:15:50+00:00Added an answer on June 18, 2026 at 4:15 am

    I couldn’t find the answer to this anywhere, and couldn’t tempt anyone into answering it either, so I worked around it by adding a span inside the cell, and setting its style like so:

                if (e.Row.Cells[i].Text.Contains("monkey"))
                {
                    e.Row.Cells[i].Text = e.Row.Cells[i].Text.Replace("monkey", "<span class=\"monkey\">monkey</span> ");
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on an ASP.Net website and have a GridView displaying some data,in
I have a fairly big asp.net website that use GridView bound to the same
i have a website page that contains only data of which one field gives
I have a website that does not have page refreshes when the visitor navigates
I have a page on a website that contains a secure form inside an
I have a website in c#, in the first page I have some listbox,
I have a table in a my Dynamic Data website that has a Primary
On my website I have a page that can only be viewed if the
I have a page on my website that I have added the Facebook like
I have a ASP.NET/VB that had a GridView to display a list of users

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.