Changing DataGrid Item BGCOLOR

G

Guest

Is there a way to change the background color of a specific item in a datagrid based on it's value? For example, assuming I have the following table layout

genr
son
lengt

If the genre is 'Rock' then I would like to give the row a different color than if the genre is 'Rap'. It seems like this would be a pretty common desire, but I haven't been able to find any documentation on it, and today I've rammed my head against the wall trying to figure out how to do this

I've tried using template columns, but I cannot get it to work to save my life... Is there a way to do this? If I cannot change the color of the entire row is there at least a way to change the bgcolor of the actual genre item based on it's value

Any input or suggestions would be highly appreciated. Or if you can point me to any helpful links I would be delighted

Thanks
JC
 
G

Guest

Ok, finally figured it out by doing a switch on e.Item.Cells[the_column] in the ItemDataBound event, and setting the Item.BackColor that way.
 

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,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top