Click here to Skip to main content
13,398,338 members (36,623 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
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 6-Oct-12 0:30am
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 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 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
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web03 | 2.8.180216.1 | Last Updated 6 Oct 2012
Copyright © CodeProject, 1999-2018
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