Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 15th, 2005, 04:27 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 130
Thanks: 0
Thanked 0 Times in 0 Posts
Default Colouring Rows in a Datagrid

I have a datagrid and I would like to be able to alter the colour of row depending upon the data in the grid for example making all customers from Kent green and Hampshire yellow. How do I do this?

Thanks

Louisa

 
Old August 15th, 2005, 07:09 AM
Friend of Wrox
 
Join Date: Apr 2004
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to RPG SEARCH
Default

try 4guysfromrolla.com they have a good guide to the datagrid....

i think an if statement might cover it like...

If DatagridLbl1.Text = "Kent" then
 ItemStyle.BackColor = Red
ElseIf Datagridlbl1.text = "Somewhere Else" then
 ItemStyle.BackColor = Pink with dots
End If

David Jenkins
-------------------------------------------------------------
Do you want to make extra money around your commitments?
Credit cards, bills, loans and a mortgage - all getting you down?
Is your pension going to be enough when you retire?
There is a solution visit http://www.1stmillion.co.uk
or call 01772 489521
 
Old August 16th, 2005, 08:51 AM
Authorized User
 
Join Date: Nov 2004
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to avanishp
Default

private void usrGrid_OnItemDataBound(object sender, DataGridItemEventArgs e )
{
 if(e.Item.Cells[0].Text=="Kent")
    e.Item.BackColor=Color.Green;
if(e.Item.Cells[0].Text=="Hampshire")
    e.Item.BackColor=Color.Yellow;
}

here Cells[0] in cell having text to check, you have to change it to cell index you have for this text.



Avanish Pandey
Set your heart upon your work, but never on its reward





Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i cover all datagrid rows ??? thomaz C# 1 November 30th, 2006 10:19 PM
Colouring records Tachyophan Access VBA 8 March 29th, 2005 09:58 AM
How to add rows in DataGrid ? vivekian ASP.NET 1.0 and 1.1 Professional 0 March 13th, 2005 04:30 AM
rows in Datagrid drachx General .NET 0 October 20th, 2004 08:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.