Changing cell colors in a datagrid based on the information contained in the cell

Any help I can get would be greatly appreciated.

I have a datagrid with information in several columns that show the status of certain aspects of a given project. Red for an area in trouble in trouble, yellow for those having problems that could become serious and green for those running as planned.
What I would like to do is have the cell color change to correspond to the status of the project. Since the project managers update the status of projects as needed the color would need to change based on the text entered into the cell turning either red, yellow or green to correspond.
How can I do this?
0
teksurf
6/17/2004 7:24:19 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

2 Replies
569 Views

Similar Articles

[PageSpeed] 39

You can do this on the ItemDataBound event, here is code


if(e.Item.ItemIndex != -1)
{
if(e.Item.Cells[1].Text == "Status")
{
e.Item.Cells[1].ForeColor = Color.Red; // this changes the font color
e.Item.Cells[1].BackColor = Color.Red; //changing the background color
}
}

0
aspdotnetv2
6/17/2004 8:29:36 PM
thanks very much for your help. i will give it a try.
0
teksurf
6/18/2004 12:18:58 PM
Reply:

Similar Artilces:

Changing data grid cell colors based on information contained within the cells #2
I posted the following question the other day and aspdotnetv2 kindly responded with some code. However this seemed to require the use of the repeater control to accomplish my goal. It worked as it should. But if I do this I loose the functionally of the "data grid" that I wanted. Does anyone know a way to accomplish this using the data grid instead of the repeater?? I have a data grid with information in several columns that show the status of certain aspects of a given project. Red for an area in trouble in trouble, yellow for those having problems that could become serious ...

Change Datagrid cell color based on cell value
I was wondering if there is a way to change the background color of an individual cell in a datagrid based on it's value. (I code in VB) Example: I have a Due Date field and the cells need to be highlighted yellow for all dates that are over 30 days old. Then for all of the dates that are over 60 days old, their cell backgrounds would need to be red. Thanks for the help in advance Dan Take a look @ Change Color of a Column Based on Column Values In your case you can use <Table> tag and change the <td> background color using helper function HTH Sushila ...

Changing DataGrid cells and child controls based on other cells values... having trouble
I am trying to examine the value of one cell, then disable other controls in the same row (in other cells) based on this. Basically if this cell = Yes or No, then disable a dropdown in another cell. I have tried the ItemCreated and ItemDataBound and am intercepting the event.itemtype by (ListItemType.Item and ListItemType.AlternatingItem) but it is telling me that value of this cell when i examine it is empty. Should i wrap the value in a label or something? I have tried that as well but it doesnt work, the value is always empty when checking during these events but at render time ...

Changing a Cells color based on another cells value
We want to change the color of a previous cell based on the value in the current cell. For example, say we are ranking items as they are read into the datagrid. We have several columns of data we want to rank for first and second place. Once we encounter a value that is greater than the previous high value we would like to change the previous high values cell color to yellow and the new high cells color to green. For example column 1 in the following table would have 12 highlighted in green and 10 highlighted in yellow. See the following table. Column 2 would have 11 highlighted green and th...

Change cell color in a cell when hyperlink is clicked
I have a table across the bottom of my form, when a user clicks a hyperlink in one of the cells, I want the bgcolor of the cell to change. You can use the onClick event of the cell to change its bgcolor property. For example:<td bgcolor="black" onclick"bgcolor='white';">This is a test!</td>This uses event propogation to capture the click event which is passed down from the link. Steven BeyRecursion: see Recursion Don't know what I'm doing wrong, I used your example and it it doesn't want to cooperate. The bgcolor automatically deafults to the oncli...

Change cell color in datagrid
Hello ppl... Do you know how can i chage color of specific cells (or items in some specific cells) in my datagrid? While putting data in dtrow i cannot put <font color='red'> tag in some columns because they contain integers and decimals Thanks in advance Bracoute Yuo can use the itemDataBound event : Sub DataGrid1_ItemBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs) If e.Item.ItemType = ListItemType.Item Or _ e.Item.ItemType = ListItemType.AlternatingItem Then ' Change the color of cell 1 with CSS ...

How to change the color of DataGrid cell ?
Can I change the color of DataGrid cell based on the value from a database? You may use "DataGrid1.Items[X].Cells[X].BackColor".This posting is provided "AS IS" with no warranties, and confers no rights. Thanks, Can you give me one example please? I used it as following but it gave me an error : MyDataGrid.Items[1].Cells[1].BackColor="blue" Regards. You may try this: MyDataGrid.Items[1].Cells[1].BackColor=Color.Blue This posting is provided "AS IS" with no warranties, and confers no rights....

Change the color of datagrid cell..
Hi Friends, I want to change datagrid cell's back color by a single click on the cell. when i click in cell color will be changed and the next click on same cell i want to get the color which was before the single click. pls help me.. thanx in advance.   See folowing article http://www.codeproject.com/aspnet/AlPaMOD.asp?df=100&forumid=51730&exp=0&select=879011.You can do similar thing on mouse click event.Arvind Malik I wrote this rather quick. The example uses a table, but a datagrid is a table.....<html>  <head>    <script type="...

Edit the cell text by clicking in the cell in datagrid control
Sir,In asp.net 2.0 application, I want to edit the cell text by clicking in the cell in datagrid control. By EditItemTemplate it is possible to edit the cell text but for that we need to click on Edit button and after edit we need to click on Update button. But this way is not accepted. Is it possible in datagrid (possibly without activex control) to click in cell and edit the value and click out of the cell to update just like windows application grid?I did not find any article on web related to this.Please help me.Thanks in advance.    &nbs...

change grid cells back color (Cells Blinks)
Dear devs my case is im building a website similar to stocks websites, i used ajax for refreshing issues and gridview for disiplaying data. now the data will change frequently and i want to color the changed data (coloring the cells of changed data). but the problem is i dont know which cell is changed and which one staied remain. thanks for helpingJaffar N. Khalid Hi:   From your description my understanding is that you're using UpdatePanel and a Timer. Is it right? If my understanding is correct you can get the original data before GridView is bound again. Store it in a globa...

Changing Font Color in Datagrid Cell
Hello everyone and thanks for your help in advance. I have an application that generates a datagrid as output. I have used CSS to format the text in each of the cells. However, I want to be able to change the color of the font in a particular cell based on the data found in that cell. I am using the OnItemDataBound handler for other functions, but don't know exactly how to reference the appropriate cell and then change the color of the font, or preferrably the CSS Class of that particular cell. Any help on this issue would be greatly appreciated. Thanks. You'll have to give e....

How to control cell colors in a datagrid(Web)
Edited by haidar_bilal - Please place your code within the < code > and < /code > tag. Thank you. Below is code which I copied from the .Net documentation: <%@ Page Language="C#" AutoEventWireup="True" %> <%@ Import Namespace="System.Data" %> <html> <script runat="server"> DataTable Store = new DataTable(); DataView StoreView; void Page_Load(Object sender, EventArgs e) { if(Session["StoreData"] == null) { Dat...

How to change fore color of a datagrid cell
Hello, I would like to change the color of my datagrid cells depending of the value of the cell. Let's say the value is >100 then the color in this cell is red and if the value <100 the the color should be green. How can I accomplish this? -Jani Hi Jani, These articles might help: http://authors.aspalliance.com/Colt/articles/article3.aspx and http://authors.aspalliance.com/Colt/articles/article1.aspx Regards, Take a look @ Change Color of a Column based on Column ValuesSushila Bowalekar PatelVisual ASP/ASP.NET MVPhttp://weblogs.asp.net/sushilasb...

Change the selected cell color in a datagrid
 I have a  datagrid with cells(with link button) containing alphabets A-Z. On click of each of the cell, record with that letter as starting letter with be displyed. My question is i want to highlight the selected alphabet with a diff. color. I have done this. But since my datagrid is withing an Ajax update panel , the panel get refreshed and the color disappers. Plzz anybody help on this Hi Geervanibs, From your description, I understand that you would like to change the selected cell’s color in the GridView. The issue is if the GridView is placed into a UpdatePanel, the color ...

Web resources about - Changing cell colors in a datagrid based on the information contained in the cell - asp.net.presentation-controls

Information - Wikipedia, the free encyclopedia
Information (shortened as info or info. ) is that which informs, i.e. an answer to a question, as well as that from which knowledge and data ...

InformationWeek – Latest Information Technology (IT) news & IT articles - Technology news - IT magazine ...
InformationWeek provides latest Information technology (IT) news online & articles and publishes latest tech news & IT magazine for Indian IT ...

Queensland weather: Latest storm warning information
PARTS of Queensland were hit by severe storms, with golf-ball-size hail in the Granite Belt Monday afternoon.

Magnetic protein may provide animals with navigation information
What do monarch butterflies, salmon, lobsters, bats, mole rats, and marine nudibranch mollusks have in common? As I'm sure you already knew, ...

Security researchers have discovered more information on how the Sony hackers managed to stay undetected ...
More details of the hack that wiped out Sony Pictures' computer systems and resulted in thousands of internal emails and documents leaking online ...

Russian plane crash: $50M reward for information - CNN.com
... plane crash in Sinai, Egypt, last month was caused by a bomb, the Russian FSB chief says, and Russia offers a $50 million reward for information. ...

The Federal Reserve Leaks Price Sensitive Information Enabling Stock Market Profits
When people say that the insiders get to make all the money in the financial markets we usually pooh pooh such conspiracy theories. For a start ...

Transpose focuses on business customers, starts charging for its information management platform
... business customers. The service began in 2014 as a note-taking application called KustomNote, but it has since grown into a more holistic information ...

UN Urges Release of All Information on Hammarskjold Death
UN urges all countries to release information on 1961 crash that killed UN chief Hammarskjold

Jenny McCarthy: Knowing co-star Charlie Sheen was HIV+ would have been 'valuable information'
Jenny McCarthy is not throwing her support behind Charlie Sheen in light of his revelation this week that he was diagnosed as HIV-positive four ...

Resources last updated: 11/26/2015 12:21:00 PM