开发者

linkbutton to expand gridview causes row colors from function to be lost

开发者 https://www.devze.com 2023-02-05 08:10 出处:网络
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 lin

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消