Changing the backcolor of a entire row in DataGrid

Posted on 2004-10-16
Last Modified: 2010-04-15
I have a Datagrid and create TableStyle and ColumnStyle for it. I want to change the backcolor of a entire row if the specific column of that row have one of my values.

ColA    ColB    ColC    ColD
1        A         a        Y
2        B         b        R
3        C         c         R
4        D         d        W
5        E         e         Y
6        F         f          W

I want to change the color of **entire** rows 1,5 to yellow.

I searched the EE and Net for it. But what I find is changing the color of a column not entire row.

Thanks for your help,
Question by:Farzad Akbarnejad

Expert Comment

ID: 12331616
You can change row colors using following code. Put this code after filling your grid. (It should be in your page_load) Remember that first rows index is zero.

dataGrid.Items[0].Style["BACKGROUND-COLOR"] = "yellow";
dataGrid.Items[4].Style["BACKGROUND-COLOR"] = "yellow";

LVL 14

Author Comment

by:Farzad Akbarnejad
ID: 12332180
my Data Grid hasn't Items member. Maybe it was in Web Controls. I am using System.Windows.Form. I am developing Windows Application.

LVL 70

Expert Comment

by:Éric Moreau
ID: 12332535
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 14

Author Comment

by:Farzad Akbarnejad
ID: 12333021
I visited your link before that I found it in EE solutions. It is about changing a cell not entire row.
I want to change the color of entire row.

I found the following link that its downloadable sample code is very valuable.
I solved my problem by helping of it.

I want to close this question with Points Refund. Any Suggestion?

LVL 70

Expert Comment

by:Éric Moreau
ID: 12333235
You have to ask a 0-point question into the community support topic

Accepted Solution

RomMod earned 0 total points
ID: 12374079
The question has been PAQ'd and the 500 points have been refunded.
Community Support Moderator

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
jquery + radiobuttonlist 3 45
C# class library debugging - Breakpoint will not hit. 8 32
Problem to Office 1 44
Adjust the codes 3 33
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 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