473,408 Members | 1,753 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,408 software developers and data experts.

changing the color of a cell in a datagrid

hello,
I'm trying to change the color of certain cells
in a datagrid according to their values?

I tried to get the value in the Datagrid_ItemCreated event but I couldn't

I don't know where else to start?

any help?
thank you
Nov 19 '05 #1
7 1858
ItemDataBound and PreRender are the right events to use.

Eliyahu

"Franck" <fh@fh.com> wrote in message
news:di**********@s1.news.oleane.net...
hello,
I'm trying to change the color of certain cells
in a datagrid according to their values?

I tried to get the value in the Datagrid_ItemCreated event but I couldn't

I don't know where else to start?

any help?
thank you

Nov 19 '05 #2
what was wrong with the _ItemCreated call?
Also, look at the _ItemBound (or is it _ItemDataBound?) event.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Franck" wrote:
hello,
I'm trying to change the color of certain cells
in a datagrid according to their values?

I tried to get the value in the Datagrid_ItemCreated event but I couldn't

I don't know where else to start?

any help?
thank you

Nov 19 '05 #3
HI,
You cant do it in the Item created event. You should do it in the itembound
event.
Regards,
P.Nishanthan
"Franck" <fh@fh.com> wrote in message
news:di**********@s1.news.oleane.net...
hello,
I'm trying to change the color of certain cells
in a datagrid according to their values?

I tried to get the value in the Datagrid_ItemCreated event but I couldn't

I don't know where else to start?

any help?
thank you

Nov 19 '05 #4
Curt_C [MVP] wrote:
what was wrong with the _ItemCreated call?
Also, look at the _ItemBound (or is it _ItemDataBound?) event.


In the ItemCreated event the data's not yet been bound to the
DataGridItem, so you can't reference the data. Hence you need to use
the ItemDataBound event, as you noted.

--

Scott Mitchell [ASP.NET MVP]
mi******@4GuysFromRolla.com
http://www.4GuysFromRolla.com/ScottMitchell
Nov 19 '05 #5
Franck wrote:
I'm trying to change the color of certain cells
in a datagrid according to their values?

I tried to get the value in the Datagrid_ItemCreated event but I couldn't


You need to use the ItemDataBound event.

Here's a FAQ that shows how to accomplish just what you're after
(coloring a cell based on the data in the cell):
http://datawebcontrols.com/faqs/Cust...rmatting.shtml

hth

--

Scott Mitchell [ASP.NET MVP]
mi******@4GuysFromRolla.com
http://www.4GuysFromRolla.com/ScottMitchell
Nov 19 '05 #6
Depending on where the data is coming from though....

But yeah, you are right. The Bound is the better place.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Scott Mitchell [MVP]" wrote:
Curt_C [MVP] wrote:
what was wrong with the _ItemCreated call?
Also, look at the _ItemBound (or is it _ItemDataBound?) event.


In the ItemCreated event the data's not yet been bound to the
DataGridItem, so you can't reference the data. Hence you need to use
the ItemDataBound event, as you noted.

--

Scott Mitchell [ASP.NET MVP]
mi******@4GuysFromRolla.com
http://www.4GuysFromRolla.com/ScottMitchell

Nov 19 '05 #7
thanks for your help
exactly what I needed :)

Scott Mitchell [MVP] wrote:
Franck wrote:
I'm trying to change the color of certain cells
in a datagrid according to their values?

I tried to get the value in the Datagrid_ItemCreated event but I couldn't

You need to use the ItemDataBound event.

Here's a FAQ that shows how to accomplish just what you're after
(coloring a cell based on the data in the cell):
http://datawebcontrols.com/faqs/Cust...rmatting.shtml
hth

Nov 19 '05 #8

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

Similar topics

2
by: Joe Smith | last post by:
Hi, I'm using the code below to change the contents of a cell table in IE. The problem is that the cell size won't adjust to the size of the content, as its positions have been declared 'absolute'....
1
by: Nelson Xu | last post by:
Does anybody can tell me how to dynamically change row color from datagrid in .net. Thanks in advance ! Nelson
2
by: Gidi | last post by:
hello, i'm writing a windows application in C#. i have a dataGrid that takes data from dataset that connected to sql stored procedure, and i have few radio buttons. i want that when ever the...
1
by: Atley | last post by:
I have been creating spreadsheets in VB.net 2003 and i can get most everythign perfect, except changing the color of the fonts and the cells, i keep getting exception errors when i try to use:...
2
by: Georg Schmelzer | last post by:
Hi Ng, I've got the following Problem: There is a windows form with one Datagrid. I set the datasource at runtime either to a at runtime designed datatable with for Columns, or to a also at...
1
by: Anup | last post by:
Hi group, I m using protected System.Web.UI.WebControls.DataGrid (ASP.NET 1.x) I have set the "pager style mode" to "NumericPages" with "AllowingPaging=true"
10
by: steve | last post by:
Hi All I would like to be able to change the cell borders on certain cells to none at runtime to make a group of cells appear to be merged I have tried the following in the cellformatting...
1
by: kanepart2 | last post by:
Hi, I have a data grid which is user editable. There are two columns Name, Status. the Name Column has a textbox and the status columns has a drop down list with two possible options True/...
1
by: Aaaaash | last post by:
how can we know which cell has been selected or clicked in DataGrid. I need to know the current Row And Column of the cell.
0
by: ziketo | last post by:
Hi, I searched a lot about changing the DataGridView cell borders. BYTES helped me so I will write down the solution: 1. You should override the class DataGridViewTextBoxCell, and the new class...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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.