INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS
Come Join Us!
Are you a
Computer / IT professional?
Join Tek-Tips now!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- One-Click Access To Your
- Automated Signatures
On Your Posts
- Best Of All, It's Free!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site
(Download This Button Today!)
"...It is good to know that there are groups such as this willing to share knowledge in this money driven economy..."
Where in the world do Tek-Tips members come from?
How can I carry out Conditional formating on a Gridview ?
Posted: 19 Jun 07
Say in your gridview you have the following data ;
Month, Target, Result
June, 0.23, 0.24
July, 0.17, 0.15
Sept, 0.25, 0.37
In your Gridview, you want to highlight the cell when the Months result is less than the Target.
What you want to do is the following.
On the RowDataBound event of the gridview add the following code.
//First check to see that we are on a data row
if (e.Row.RowType == DataControlRowType.DataRow)
//now convert the text value to a double (use int32 for whole numbers)
if (Double.Parse(e.Row.Cells.Text) < Double.Parse(e.Row.Cells.Text))
//set the background to red
//you can also access other properties such as font from here, as below
e.Row.Cells.Font.Bold = true;
Back to Microsoft: ASP.NET FAQ Index
Back to Microsoft: ASP.NET Forum
Join Tek-Tips® Today!
Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.
Here's Why Members Love Tek-Tips Forums:
- Talk To Other Members
- Notification Of Responses To Questions
- Favorite Forums One Click Access
- Keyword Search Of All Posts, And More...
Register now while it's still free!
Already a member? Close this window and log in.
Join Us Close