感谢 Anton,但我已经用 javascript 完成了。我正在使用如下表的偶数和奇数属性。这是我在 document.ready 函数中调用的函数。并从服务器端调用每个按钮的点击事件。
函数颜色网格(){
/*code for color coding grid*/
$(".student_account td table tbody tr'[id]':odd").addClass('initial');
$(".student_account td table tbody tr'[id]':even").addClass('initial');
/* For odd Rows */
// for first 3 columns
$(".student_account td table tbody tr'[id]':odd td:nth-child(1)").css("background-color", "#EEEEEE");
$(".student_account td table tbody tr'[id]':odd td:nth-child(2)").css("background-color", "#EEEEEE");
$(".student_account td table tbody tr'[id]':odd td:nth-child(3)").css("background-color", "#EEEEEE");
// for 4th and 5th column
$(".student_account td table tbody tr'[id]':odd td:nth-child(4)").css("background-color", "#EBFAE3");
$(".student_account td table tbody tr'[id]':odd td:nth-child(5)").css("background-color", "#EBFAE3");
// for 6th t0 9th column
$(".student_account td table tbody tr'[id]':odd td:nth-child(6)").css("background-color", "#F7F8D6");
$(".student_account td table tbody tr'[id]':odd td:nth-child(7)").css("background-color", "#F7F8D6");
$(".student_account td table tbody tr'[id]':odd td:nth-child(8)").css("background-color", "#F7F8D6");
$(".student_account td table tbody tr'[id]':odd td:nth-child(9)").css("background-color", "#F7F8D6");
// for 10th column
$(".student_account td table tbody tr'[id]':odd td:nth-child(10)").css("background-color", "#CBE6F7");
/* For Even Rows */
var name = "ctl00_ContentPlaceHolder1_grdScheduleStudent_DXHeadersRow";
// for first 3 columns
$(".student_account td table tbody tr'[id]':even td:nth-child(1)").css("background-color", "#FFFFFF");
$(".student_account td table tbody tr'[id]':even td:nth-child(2)").css("background-color", "#FFFFFF");
$(".student_account td table tbody tr'[id]':even td:nth-child(3)").css("background-color", "#FFFFFF");
// for 4th and 5th column
$(".student_account td table tbody tr'[id]':even td:nth-child(4)").css("background-color", "#F5FAF3");
$(".student_account td table tbody tr'[id]':even td:nth-child(5)").css("background-color", "#F5FAF3");
// for 6th t0 9th column
$(".student_account td table tbody tr'[id]':even td:nth-child(6)").css("background-color", "#FBFCEA");
$(".student_account td table tbody tr'[id]':even td:nth-child(7)").css("background-color", "#FBFCEA");
$(".student_account td table tbody tr'[id]':even td:nth-child(8)").css("background-color", "#FBFCEA");
$(".student_account td table tbody tr'[id]':even td:nth-child(9)").css("background-color", "#FBFCEA");
// for 10th column
$(".student_account td table tbody tr'[id]':even td:nth-child(10)").css("background-color", "#EDF8FE");
$(".student_account td table tbody tr'[id=" + name + "]' td").css("background-color", "#56A52E");
/*end color coding*/
}