Setting color for a single cell in a datagrid.

U

UJ

How can I set the background color for a single cell dynamically in a
datagrid control? I know how to do the entire row but not the cell.

TIA - Jeff.
 
E

Eliyahu Goldin

You need first to navigate to the cell and then set its BackColor property.
Navigation to cell depends on in what place in the code you want to do it.
If you are in the ItemDataBound event, which is the most common place for
handling this sort of tasks, you get a reference to the datagrid item (row)
as a parameter and you can use Cells collection to get to the cell. In
PageLoad or PreRender event you first navigate to the row in the grid and
then to the cell.
 

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

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top