473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Different backgroundcolor depending on value in datagrid

I have a datagrid on a webform with one field containing values 0, 1 and 2.
I want to have the background green when the value is 0, yellow when the
value is 1 ...
I insert the code in the html part.

The code is
<script language="C#" runat="server">
private void masterDataGrid_ItemDataBound (object sender,
DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
TableCell cell = e.Item.Cells[2];
int A1 = int.Parse(cell.Text);
if (A1 == 0)
{
cell.BackColor = Color.Yellow;
}
else
{
if (A1 == 1)
{
cell.BackColor = Color.Green;
}
else
{
cell.BackColor = Color.Red;
}
}
}
}
</script>
The compilation stops at cell.backcolor = color.Yellow;

regards
reidarT
Nov 17 '05 #1
0 966

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Philip | last post by:
Hey, Is it possible to get the default value of an element's style.backgroundColor property that's set in a css class? Example, since I'm very tired and can't word that any better ;) ...
1
by: RobG | last post by:
When I set the background colour of an element using tdRef.style.backgroundColor and then read it back, Firefox always gives rgb(r, g, b) regardless of whether I've used rgb(...) or #rrggbb to set...
13
by: cosmic foo | last post by:
if i change the backgroundColor of a tag to 'red', it works in both ie and mozilla. if i change the backgroundColor of a tag to 'redd', i get 'invalid property value' in ie, and no error in...
0
by: M.Sauve | last post by:
Hi I want to compare 02 columns in my datagrid and for example if my column5 < column6 I want to color my columns 5 and 6. This is my code and I'm not able to get the value of column6 in my...
0
by: ReidarT | last post by:
I have a datagrid on a webform with one field containing values 0, 1 and 2. I want to have the background green when the value is 0, yellow when the value is 1 ... I insert the code in the html...
0
by: John | last post by:
Hi! Guys I think some of you can help me here. Here is the situation...... I have a following columns from different tables and get a Dataset to Bind with a data grid. 1)ItemId int...
6
by: fallen angel | last post by:
halu there!! i'm a 1month experienced java scripter but got a good hang of it already. hehehe.. i developed a "color selection" tool, similar to the one in flash when you choose a color for a...
10
by: Cliff Cotterill | last post by:
I've tried multiple ways of setting the background-color of a DropDownList, but none seem to work. How can the color be set? I've tried setting the BackGroundColor of the DrowDownList component,...
4
by: André | last post by:
Hi, i created a table with cells. One cell has background-color (LightSlateGray) and contains a label without text but also with a backgroundcolor (red). The width of the label is set by a value...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.