用于扩展gridview的linkbutton会导致函数的行颜色丢失

时间:2022-08-04 13:57:59

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.

当我在gridview中有一个链接按钮扩展表格以显示嵌套的gridview时,我会丢失从此函数中获得的所有行颜色。我需要的是一种在单击链接按钮时调用该函数的方法。

 <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({ "background-color": "RED" });

            }
               else if (status == 'CL') {
                $(this).children('td').css({ "background-color": "YELLOW" });


            }

            })
        });


</script>

1 个解决方案

#1


1  

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.

至于它会解决你所问的问题,我不确定。

#1


1  

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.

至于它会解决你所问的问题,我不确定。