When a Link button I have in my gridview that expands the table to show a nested gridview i lose all the row colors that i get from this function. What I need is a way to call the function when the link button is clicked.
<script type="text/javascript">
$(document).ready(function () {
$("#<%=GridView1.UniqueID%> tr").each(function () {
var status = $(this).children('td:eq(6)').text();
if (status == 'OK') {
$(this).children('td').css({ "background-color": "lightgreen" });
}
else if (status == 'XL') {
$(this).children('td').css({ 开发者_StackOverflow社区"background-color": "RED" });
}
else if (status == 'CL') {
$(this).children('td').css({ "background-color": "YELLOW" });
}
})
});
</script>
I can see one problem with this code :
Your last function will override all others(i think) Why don't you try:
$(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" });
}
else if (number == 'XL') {
$(this).children('td').css({ "background-color": "RED" });
}
else if (number == 'CL') {
$(this).children('td').css({ "background-color": "YELLOW" });
}
})
});
As for it will solve what you are asking about, I am not sure.
精彩评论