473,397 Members | 2,099 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,397 software developers and data experts.

data grid conditional row formatting

How would i format a web data grid conditionally?

If column 1 is the value true i want the row to be white, else if it is
false i want the row to be blue, thanks
Nov 18 '05 #1
2 2050

use ItemDataBound event of datagrid control
and

private void DataGrid1_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if ( e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem )
{
string color = "";
if ( bool.Parse(e.Item.Cells[0].Text) )
color = "#FF0000";
else
color = "#00FFFF";

for ( int i=0; i < e.Item.Cells.Count; i ++ )
{
e.Item.Cells[i].BackColor = Color.FromName(color);
}
}
}

where in the first column i have the true/false value as a text

Regards
Martin
"Brian Henry" <br**********@newsgroups.nospam> wrote in message
news:#H**************@tk2msftngp13.phx.gbl...
How would i format a web data grid conditionally?

If column 1 is the value true i want the row to be white, else if it is
false i want the row to be blue, thanks

Nov 18 '05 #2
thanks

"Martin Marinov" <me********@mecrossroad.bg> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...

use ItemDataBound event of datagrid control
and

private void DataGrid1_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if ( e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem )
{
string color = "";
if ( bool.Parse(e.Item.Cells[0].Text) )
color = "#FF0000";
else
color = "#00FFFF";

for ( int i=0; i < e.Item.Cells.Count; i ++ )
{
e.Item.Cells[i].BackColor = Color.FromName(color);
}
}
}

where in the first column i have the true/false value as a text

Regards
Martin
"Brian Henry" <br**********@newsgroups.nospam> wrote in message
news:#H**************@tk2msftngp13.phx.gbl...
How would i format a web data grid conditionally?

If column 1 is the value true i want the row to be white, else if it is
false i want the row to be blue, thanks


Nov 18 '05 #3

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

Similar topics

3
by: Jouke Langhout | last post by:
Hello all! For quite some time now, I've got the following problem: Access won't close properly when a user closes the application. An ACCESS process stays active and that process can only be...
4
by: Bradley | last post by:
I have an A2000 database in which I have a continuous form with a tick box. There is also a text box with a conditional format that is based on the expression , if it's true then change the...
8
by: Dimitri Furman | last post by:
Given: Access 2002/2003 A subform in datasheet or continuous view, placed on a tab page (this last may or may not matter) Conditional formatting applied to some controls on the subform - format...
5
by: Andrew Chanter | last post by:
Does anyone know a way you can use conditional formatting to create a banded style view as is commonly seen on the internet. (In othe words the first record appears on a gray background, the 2nd...
1
by: GGerard | last post by:
Hello Is there a way to use a variable in the Conditional Formatting of a Textbox? Example : I want the background of a textbox in a continuous form to change color when the value of...
1
by: Jay | last post by:
hi all, how to color/ highlight the different cells of a win form data grid. my requirement is to highlight all the cells having null values or failing the rules defines. or atlest how to get to a...
8
by: Typehigh | last post by:
I have many text fields with conditional formatting applied, specifically when the condition is "Field Has Focus". Without any events associated with the fields the conditional formatting works...
4
by: midlothian | last post by:
Hello, I have conditional formatting set up on a subform based on a calculated value in the underlying query. For instance, if Sales are >$1000, the query displays "Yes," otherwise it displays...
4
by: Keith G Hicks | last post by:
I have a gridview (asp.net 2.0) where I'm trying to format rows based on a NON VISIBLE column. It doesn't seem to work. When column 0 below is visible, the row is formatted as expected but when...
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: 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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.