Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET Gridview
Dear Friends, Good Day to all of u.
 
am working on School Project.
 
I have a Student Database with Student Marks.
 
i have displayed this data in Gridview...it working fine.
 
I have Database Fields as
 
Name Class Section Result Percentage
===========================================
Arun 10 A Pass 89
Kishore 10 A Fail 95
Sandeep 10 B Fail 29
 

So, My Requirement is whereever fail is displayed in Gridview it must change the background color of cell to red.
 

Please help me, How to do this ? ?
 
Thanks.
Posted 5-Oct-12 23:30pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

hi,
 
You can change the gridview's cell backcolor in ondatabound event of the gridview.
 
Go through the links
 
http://highoncoding.com/Articles/180_Changing_GridView_Column_Color.aspx[^]
 
change cell color of GRIDVIEW based on system date[^]
  Permalink  
v2
Comments
Ubaid ur Rahman IT at 6-Oct-12 5:38am
   
Ya i know in Databound event.
 
But Please tell me, WhereEver I find FAIL in Total Gridview it must change the cell background to Red.
 
Please help.
VijayChauhan123 at 6-Oct-12 5:45am
   
please find the links
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,
 
You need to check if the value is less then the passing marks in OnRowDataBound[^] event of the gridview. And to change the color of that cell you can simply use
 
args.Row.Cells[columnindex].BackColor = Your Color;
 
Hope it helps you,
Thanks
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 540
1 CPallini 290
2 OriginalGriff 265
3 ChauhanAjay 124
4 George Jonsson 120
0 OriginalGriff 6,474
1 Sergey Alexandrovich Kryukov 6,190
2 CPallini 5,180
3 George Jonsson 3,574
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 6 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100