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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:23:42+00:00 2026-05-23T05:23:42+00:00

I am getting there! Need a tiny bit of extra help. My gridview has

  • 0

I am getting there! Need a tiny bit of extra help.
My gridview has 2 columns. One is Party (text) and one is a Select column with a Select button in every row.
This is what I want: Change the color of the Select button to Red if the Party is Republican. Otherwise set it to Blue.
Below is the code I have. Please help me fill in the missing code.

protected void GridView1_RowDataBound1(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (e.Row.Cells[0].Text == "Republican")
                 {
                  // WHAT SHOULD I DO HERE???
                 }
        }


    }
  • 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-23T05:23:43+00:00Added an answer on May 23, 2026 at 5:23 am

    Instead of setting the color in the codebehind you could just set the CSS Class of your button in the aspx file, using gridview’s template fields:

    <templateField>
        <itemtemplate>
            <asp:button runat="server" id="selectButton" CSSClass='<%# Eval("PARTY") %>' />
        </itemTemplate>
    </templateField>
    

    and then defining the CSS Class in your stylesheet.

    .republican{background-color:#F00;}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there has to be a way: I need help getting any hot
Is there a search API for getting a short text containing the search terms
I know there is this one: sizeWithFont:minFontSize:actualFontSize:forWidth:lineBreakMode: But since the CGSize always has the
When i am doing Deserialize of xml i am getting There is an error
Greets! I'm a noob struggling to learn html and javascript - getting there slowly.
I know there are many tutorials out there for getting started in C. However
Is there some trick to getting a SpringMVC custom view to cause a file
Is there a neat way of getting a Locale instance from its programmatic name
Is there a way of getting around circular unit references in Delphi? Maybe a
Is there any real workaround to getting the Express edition of C# connected to

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.