I have an sqldatasource that loads, data from my server and puts it in a datagrid.
I have a Column named clnumber that has, the numbers 1,2,3
What I want is that each row have a different color depending on which number is in that datarow column
THIS IS THE CODE I USED
$(document).ready(function () {
$("#<%=GridView1.UniqueID%> tr").each(function () {
var number = $(this).children('td:eq(6)').text();
if (number == 'OK') {
$(this).children('td').css({ "background-color": "lightgreen" });
}
})
});
Granted you’ve given your gridview a css class called ‘myGridView’ you could do the following:
where ‘td:eq(1)’ refers to the second cell in a row. This of course will depend on what cell in your row contains this magic number.
I’m certain it’s not the most elegant use of jQuery, but you could refactor it as you wish