Changing DataGrid Item BGCOLOR

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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.
 
Back
Top