Datagrid - Formatting based on values

S

Simon Harris

Hi All,

I wish to change the background colour and contents of a datagrid cell based
on the value of one of the columns on a per row basis. So, for example, if
column A's value is 1, column 2 should be red with 'No' written in it. If
column A's value is 0, column 2 should be green with 'Yes' written in it.

Can anyone advise how I could achieve this? (I know how to display/populate
the datagrid).

Thanks,
Simon.
 
E

Eliyahu Goldin

Simon,

Most flexible way is to use ItemDataBound event. Event handler gets
reference to an item which represents the grid row. You have access to the
item cells (row columns) and can get/set cells properties programmatically.

Eliyahu
 
S

Simon Harris

Thank you! :)

Eliyahu Goldin said:
Simon,

Most flexible way is to use ItemDataBound event. Event handler gets
reference to an item which represents the grid row. You have access to the
item cells (row columns) and can get/set cells properties
programmatically.

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top