473,396 Members | 2,030 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,396 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 967

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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.